Skip to content

Commit ea431b9

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

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

assets/l10n/app_en.arb

+5
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

+1
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ class UpdateMachine {
794794
switch (e) {
795795
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
796796
assert(debugLog('Lost event queue for $store. Replacing…'));
797+
reportErrorToUserBriefly(localizations.errorReconnectingToServer(serverUrl));
797798
await store._globalStore._reloadPerAccount(store.accountId);
798799
dispose();
799800
debugLog('… Event queue replaced.');

test/model/store_test.dart

+6
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ void main() {
405405
}
406406

407407
test('handles expired queue', () => awaitFakeAsync((async) async {
408+
reportErrorToUserBriefly = logAndReportErrorToUserBriefly;
409+
addTearDown(() => reportErrorToUserBriefly = defaultReportErrorToUserBriefly);
410+
408411
await prepareStore();
409412
updateMachine.debugPauseLoop();
410413
updateMachine.poll();
@@ -418,7 +421,10 @@ void main() {
418421
});
419422
updateMachine.debugAdvanceLoop();
420423
async.flushMicrotasks();
424+
check(lastReportedError).isNull();
421425
await Future<void>.delayed(Duration.zero);
426+
check(takeLastReportedError()).isNotNull()
427+
.contains('Reconnecting to ${eg.realmUrl.origin}…');
422428
check(store).isLoading.isTrue();
423429

424430
// The global store has a new store.

0 commit comments

Comments
 (0)