fix(chat): fix jump-to-oldest-unread scroll not reaching target message

- Pass initialUnreadCount to chat screens before markRead clears it
- Use two-phase scroll: jumpTo estimated offset to build lazy items,
  then ensureVisible for precise positioning
- Await ensureVisible before clearing scroll guard to prevent
  scrollToBottomIfAtBottom from overriding the animation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dmitry Polshakov
2026-04-25 09:00:22 +03:00
parent a4bbeffddc
commit 3ea2e4763e
6 changed files with 107 additions and 33 deletions
+10 -3
View File
@@ -1391,11 +1391,18 @@ class _MapScreenState extends State<MapScreen> {
room: room,
// onLogin(password, isAdmin) isAdmin not used for room caht screen
onLogin: (password, _) {
// Navigate to chat screen after successful login
context.read<MeshCoreConnector>().markContactRead(room.publicKeyHex);
final connector = context.read<MeshCoreConnector>();
final unread =
connector.getUnreadCountForContactKey(room.publicKeyHex);
connector.markContactRead(room.publicKeyHex);
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChatScreen(contact: room)),
MaterialPageRoute(
builder: (context) => ChatScreen(
contact: room,
initialUnreadCount: unread,
),
),
);
},
),