Skip to content

Commit 1cfd40a

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

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 {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
@@ -793,6 +793,8 @@ class UpdateMachine {
793793
switch (e) {
794794
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
795795
assert(debugLog('Lost event queue for $store. Replacing…'));
796+
reportErrorToUserInSnackBar(localizations.errorReconnectingToServer(
797+
store.connection.realmUrl.origin));
796798
await store._globalStore._reloadPerAccount(store.accountId);
797799
dispose();
798800
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 ${eg.realmUrl.origin}…');
410413
check(store).isLoading.isTrue();
411414

412415
// The global store has a new store.

0 commit comments

Comments
 (0)