Matthias Nott
2026-03-22 16ffd8b7d28ec04b7591d08cb654148545d8598e
fix: await cross-session message storage before switch
1 files modified
changed files
lib/screens/chat_screen.dart patch | view | blame | history
lib/screens/chat_screen.dart
....@@ -387,10 +387,10 @@
387387 }
388388
389389 /// Store a message for a non-active session so it persists when the user switches to it.
390
- void _storeForSession(String sessionId, Message message) {
391
- MessageStore.loadAll(sessionId).then((existing) {
392
- MessageStore.save(sessionId, [...existing, message]);
393
- });
390
+ Future<void> _storeForSession(String sessionId, Message message) async {
391
+ final existing = await MessageStore.loadAll(sessionId);
392
+ MessageStore.save(sessionId, [...existing, message]);
393
+ await MessageStore.flush();
394394 }
395395
396396 void _incrementUnread(String sessionId) {