Matthias Nott
8 days ago 52ecd96b051a66095b96e642c49c8d0daaf53e00
lib/screens/chat_screen.dart
....@@ -220,7 +220,7 @@
220220 // Delay sync slightly to let broker acknowledge our subscriptions first.
221221 // Without this, the catch_up response arrives before pailot/control/out
222222 // subscription is active, and the message is lost.
223
- Future.delayed(const Duration(milliseconds: 500), () {
223
+ Future.delayed(const Duration(milliseconds: 200), () {
224224 if (!mounted) return;
225225 final activeId = ref.read(activeSessionIdProvider);
226226 _sendCommand('sync', activeId != null ? {'activeSessionId': activeId} : null);
....@@ -263,11 +263,11 @@
263263 // sent immediately if already connected.
264264 _push = PushService(mqttService: _ws!);
265265 _push!.onNotificationTap = (data) {
266
- // Only switch if tapping a notification for a DIFFERENT session.
267
- // If already on this session, the message is already displayed —
268
- // calling switchSession would reload from disk and lose it.
269266 final sessionId = data['sessionId'] as String?;
270267 final activeId = ref.read(activeSessionIdProvider);
268
+ // Immediately request catch_up — don't wait for the sync flow.
269
+ // The message is already in the server queue.
270
+ _sendCommand('catch_up', {'lastSeq': _lastSeq});
271271 if (sessionId != null && sessionId != activeId && mounted) {
272272 _switchSession(sessionId);
273273 }