From 0e5f1a45c45c27915ae8c811f8d5a52e8b991bd9 Mon Sep 17 00:00:00 2001 From: zjs81 Date: Mon, 27 Apr 2026 13:07:16 -0700 Subject: [PATCH] fix(chat): address mark-as-unread double-pop and missed map entry point - Remove stray Navigator.pop(context) in _markAsUnread for both contact and channel chats so the action no longer exits the conversation - Thread initialUnreadCount through map discovered-contact "Open Chat" button so the unread divider/jump still fires from that entry point Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/screens/channel_chat_screen.dart | 1 - lib/screens/chat_screen.dart | 1 - lib/screens/map_screen.dart | 7 ++++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index 2207fd5f..9393a27a 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -400,7 +400,6 @@ class _ChannelChatScreenState extends State { if (found && !m.isOutgoing) count++; } connector.setChannelUnreadCount(widget.channel.index, count); - Navigator.pop(context); } Widget _buildMessageBubble(ChannelMessage message, double textScale) { diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index 3d29fc30..62268f03 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -543,7 +543,6 @@ class _ChatScreenState extends State { if (found && !m.isOutgoing && !m.isCli) count++; } connector.setContactUnreadCount(widget.contact.publicKeyHex, count); - Navigator.pop(context); } Widget _buildInputBar(MeshCoreConnector connector) { diff --git a/lib/screens/map_screen.dart b/lib/screens/map_screen.dart index 36a9fd64..39d42a49 100644 --- a/lib/screens/map_screen.dart +++ b/lib/screens/map_screen.dart @@ -1463,11 +1463,16 @@ class _MapScreenState extends State { if (!contact.isActive) { connector.importDiscoveredContact(contact); } + final unread = + connector.getUnreadCountForContactKey(contact.publicKeyHex); Navigator.pop(dialogContext); Navigator.push( context, MaterialPageRoute( - builder: (context) => ChatScreen(contact: contact), + builder: (context) => ChatScreen( + contact: contact, + initialUnreadCount: unread, + ), ), ); },