Skip to content

Commit b87a038

Browse files
committed
store [nfc]: Manage isLoading alongside error logic in poll
This is basically a form of error reporting.
1 parent b97601f commit b87a038

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/model/store.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,6 @@ class UpdateMachine {
10291029
if (_disposed) return;
10301030
} catch (e) {
10311031
if (_disposed) return;
1032-
store.isLoading = true;
1033-
10341032
final shouldRetry = _triagePollRequestError(e);
10351033
if (!shouldRetry) rethrow;
10361034
await (backoffMachine ??= BackoffMachine()).wait();
@@ -1056,7 +1054,6 @@ class UpdateMachine {
10561054
// and failures, the successes themselves should space out the requests.
10571055
backoffMachine = null;
10581056

1059-
store.isLoading = false;
10601057
_clearReportingErrorsToUser();
10611058

10621059
final events = result.events;
@@ -1083,7 +1080,6 @@ class UpdateMachine {
10831080
// or an unexpected exception representing a bug in our code or the server.
10841081
// Either way, the show must go on. So reload server data from scratch.
10851082

1086-
store.isLoading = true;
10871083
final isUnexpected = _triagePollError(e);
10881084

10891085
if (isUnexpected) {
@@ -1110,6 +1106,7 @@ class UpdateMachine {
11101106
int _accumulatedTransientFailureCount = 0;
11111107

11121108
void _clearReportingErrorsToUser() {
1109+
store.isLoading = false;
11131110
_accumulatedTransientFailureCount = 0;
11141111
reportErrorToUserBriefly(null);
11151112
}
@@ -1120,6 +1117,8 @@ class UpdateMachine {
11201117
/// after reporting the error if appropriate to the user and/or developer.
11211118
/// Otherwise, this method returns false with no side effects.
11221119
bool _triagePollRequestError(Object error) {
1120+
store.isLoading = true;
1121+
11231122
if (error is! ApiRequestException) {
11241123
// Some unexpected error, outside even making the HTTP request.
11251124
// Definitely a bug in our code.
@@ -1167,6 +1166,8 @@ class UpdateMachine {
11671166
/// Reports the error if appropriate to the user and/or developer;
11681167
/// then returns true just if the error was unexpected.
11691168
bool _triagePollError(Object error) {
1169+
store.isLoading = true;
1170+
11701171
bool isUnexpected;
11711172
switch (error) {
11721173
case ZulipApiException(code: 'BAD_EVENT_QUEUE_ID'):

0 commit comments

Comments
 (0)