Skip to content

Commit 01abc55

Browse files
committed
store: Show error message when replacing event queue
Fixes: zulip#555 Signed-off-by: Zixuan James Li <[email protected]>
1 parent fdd7c80 commit 01abc55

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@
172172
"error": {"type": "String", "example": "Invalid format"}
173173
}
174174
},
175+
"errorReconnectingToServer": "Reconnecting to {serverUrl}…",
176+
"@errorReconnectingToServer": {
177+
"serverUrl": {"type": "String", "example": "http://example.com/"},
178+
"description": "Message when reconnecting to the server."
179+
},
175180
"errorSharingFailed": "Sharing failed",
176181
"@errorSharingFailed": {
177182
"description": "Error message when sharing a message failed."

lib/model/store.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ class UpdateMachine {
959959
switch (e) {
960960
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
961961
assert(debugLog('Lost event queue for $store. Replacing…'));
962+
reportErrorToUserBriefly(localizations.errorReconnectingToServer(serverUrl));
962963
// This disposes the store, which disposes this update machine.
963964
await store._globalStore._reloadPerAccount(store.accountId);
964965
debugLog('… Event queue replaced.');

test/model/store_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ void main() {
561561
}
562562

563563
test('handles expired queue', () => awaitFakeAsync((async) async {
564+
reportErrorToUserBriefly = logAndReportErrorToUserBriefly;
565+
addTearDown(() => reportErrorToUserBriefly = defaultReportErrorToUserBriefly);
566+
564567
await prepareStore();
565568
updateMachine.debugPauseLoop();
566569
updateMachine.poll();
@@ -574,7 +577,10 @@ void main() {
574577
});
575578
updateMachine.debugAdvanceLoop();
576579
async.flushMicrotasks();
580+
check(lastReportedError).isNull();
577581
await Future<void>.delayed(Duration.zero);
582+
check(takeLastReportedError()).isNotNull()
583+
.contains('Reconnecting to ${eg.realmUrl.origin}…');
578584
check(store).isLoading.isTrue();
579585

580586
// The global store has a new store.

0 commit comments

Comments
 (0)