Skip to content

Commit 63293f6

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

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
@@ -812,6 +812,7 @@ class UpdateMachine {
812812
switch (e) {
813813
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
814814
assert(debugLog('Lost event queue for $store. Replacing…'));
815+
reportErrorToUserBriefly(localizations.errorReconnectingToServer(serverUrl));
815816
await store._globalStore._reloadPerAccount(store.accountId);
816817
dispose();
817818
debugLog('… Event queue replaced.');

test/model/store_test.dart

+6
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ void main() {
412412
}
413413

414414
test('handles expired queue', () => awaitFakeAsync((async) async {
415+
reportErrorToUserBriefly = logAndReportErrorToUserBriefly;
416+
addTearDown(() => reportErrorToUserBriefly = defaultReportErrorToUserBriefly);
417+
415418
await prepareStore();
416419
updateMachine.debugPauseLoop();
417420
updateMachine.poll();
@@ -425,7 +428,10 @@ void main() {
425428
});
426429
updateMachine.debugAdvanceLoop();
427430
async.flushMicrotasks();
431+
check(lastReportedError).isNull();
428432
await Future<void>.delayed(Duration.zero);
433+
check(takeLastReportedError()).isNotNull()
434+
.contains('Reconnecting to ${eg.realmUrl.origin}…');
429435
check(store).isLoading.isTrue();
430436

431437
// The global store has a new store.

0 commit comments

Comments
 (0)