From 52ecd96b051a66095b96e642c49c8d0daaf53e00 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Mon, 06 Apr 2026 17:04:58 +0200
Subject: [PATCH] fix: faster notification tap - immediate catch_up, reduced sync delay to 200ms
---
lib/screens/chat_screen.dart | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart
index ee0f68b..1622283 100644
--- a/lib/screens/chat_screen.dart
+++ b/lib/screens/chat_screen.dart
@@ -220,7 +220,7 @@
// Delay sync slightly to let broker acknowledge our subscriptions first.
// Without this, the catch_up response arrives before pailot/control/out
// subscription is active, and the message is lost.
- Future.delayed(const Duration(milliseconds: 500), () {
+ Future.delayed(const Duration(milliseconds: 200), () {
if (!mounted) return;
final activeId = ref.read(activeSessionIdProvider);
_sendCommand('sync', activeId != null ? {'activeSessionId': activeId} : null);
@@ -263,11 +263,11 @@
// sent immediately if already connected.
_push = PushService(mqttService: _ws!);
_push!.onNotificationTap = (data) {
- // Only switch if tapping a notification for a DIFFERENT session.
- // If already on this session, the message is already displayed —
- // calling switchSession would reload from disk and lose it.
final sessionId = data['sessionId'] as String?;
final activeId = ref.read(activeSessionIdProvider);
+ // Immediately request catch_up — don't wait for the sync flow.
+ // The message is already in the server queue.
+ _sendCommand('catch_up', {'lastSeq': _lastSeq});
if (sessionId != null && sessionId != activeId && mounted) {
_switchSession(sessionId);
}
--
Gitblit v1.3.1