Skip to content

Commit 22f4bb9

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

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

assets/l10n/app_en.arb

+5
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@
180180
"error": {"type": "String", "example": "Network request failed: HTTP status 500"}
181181
}
182182
},
183+
"errorReconnectingToServer": "Reconnecting to server at {url}...",
184+
"@errorReconnectingToServer": {
185+
"url": {"type": "String", "example": "http://example.com/"},
186+
"description": "Message when reconnecting to the server."
187+
},
183188
"errorSharingFailed": "Sharing failed",
184189
"@errorSharingFailed": {
185190
"description": "Error message when sharing a message failed."

lib/model/store.dart

+2
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ class UpdateMachine {
789789
switch (e) {
790790
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
791791
assert(debugLog('Lost event queue for $store. Replacing…'));
792+
reportErrorToUserInSnackBar(localizations.errorReconnectingToServer(
793+
store.connection.realmUrl.origin));
792794
await store._globalStore._reloadPerAccount(store.accountId);
793795
dispose();
794796
debugLog('… Event queue replaced.');

test/model/store_test.dart

+3
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ void main() {
406406
});
407407
updateMachine.debugAdvanceLoop();
408408
async.flushMicrotasks();
409+
check(debugLastReportedError).isNull();
409410
await Future<void>.delayed(Duration.zero);
411+
check(debugTakeLastReportedError()).isNotNull()
412+
.contains('Reconnecting to server at ${eg.realmUrl.origin}...');
410413
check(store).isLoading.isTrue();
411414

412415
// The global store has a new store.

0 commit comments

Comments
 (0)