Skip to content

Commit c1cde16

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

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
@@ -797,6 +797,7 @@ class UpdateMachine {
797797
switch (e) {
798798
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):
799799
assert(debugLog('Lost event queue for $store. Replacing…'));
800+
reportErrorToUserBriefly(localizations.errorReconnectingToServer(serverUrl));
800801
await store._globalStore._reloadPerAccount(store.accountId);
801802
dispose();
802803
debugLog('… Event queue replaced.');

test/model/store_test.dart

+6
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ void main() {
409409
}
410410

411411
test('handles expired queue', () => awaitFakeAsync((async) async {
412+
reportErrorToUserBriefly = logAndReportErrorToUserBriefly;
413+
addTearDown(() => reportErrorToUserBriefly = defaultReportErrorToUserBriefly);
414+
412415
await prepareStore();
413416
updateMachine.debugPauseLoop();
414417
updateMachine.poll();
@@ -422,7 +425,10 @@ void main() {
422425
});
423426
updateMachine.debugAdvanceLoop();
424427
async.flushMicrotasks();
428+
check(lastReportedError).isNull();
425429
await Future<void>.delayed(Duration.zero);
430+
check(takeLastReportedError()).isNotNull()
431+
.contains('Reconnecting to ${eg.realmUrl.origin}…');
426432
check(store).isLoading.isTrue();
427433

428434
// The global store has a new store.

0 commit comments

Comments
 (0)