Skip to content

Commit ebe5f70

Browse files
committed
store [nfc]: Re-query account after _registerQueueWithRetry async gap
I believe this is NFC because: - the only fields we read are zulipVersion, zulipMergeBase, and zulipFeatureLevel - we read those fields only to update them if needed - nothing else could have written to those fields during the async gap; this register-queue codepath is the only codepath that writes to them, and we don't allow concurrent register-queues for an account But we've been using an Account object from across an async gap, and that looks like a code smell that calls for a fix.
1 parent 8228d97 commit ebe5f70

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/model/store.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,8 @@ class UpdateMachine {
10011001
final t = (stopwatch..stop()).elapsed;
10021002
assert(debugLog("initial fetch time: ${t.inMilliseconds}ms"));
10031003

1004+
// `!` is OK because _registerQueueWithRetry would have thrown if no account
1005+
account = globalStore.getAccount(accountId)!;
10041006
if (initialSnapshot.zulipVersion != account.zulipVersion
10051007
|| initialSnapshot.zulipMergeBase != account.zulipMergeBase
10061008
|| initialSnapshot.zulipFeatureLevel != account.zulipFeatureLevel) {

0 commit comments

Comments
 (0)