Skip to content

Commit 90cb63a

Browse files
gnpricechrisbobbe
authored andcommitted
store: Extract self-user up front; require to be present
We'll want to pass this to RealmStoreImpl soon, in order to interpret permissions correctly. In the series of commits leading up to here, we've already adapted all the tests' data to satisfy this invariant.
1 parent 6bdbf1e commit 90cb63a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/model/store.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,22 @@ class PerAccountStore extends PerAccountStoreBase with
481481
accountId: accountId,
482482
selfUserId: account.userId,
483483
);
484-
final realm = RealmStoreImpl(core: core, initialSnapshot: initialSnapshot);
484+
485485
final userMap = UserStoreImpl.userMapFromInitialSnapshot(initialSnapshot);
486+
final selfUser = userMap[core.selfUserId];
487+
if (selfUser == null) {
488+
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
489+
reportErrorToUserModally(
490+
zulipLocalizations.errorCouldNotConnectTitle,
491+
message: zulipLocalizations.errorMalformedResponseWithCause(200,
492+
// skip-i18n: This would be an unlikely bug (in the server?). We're
493+
// showing the user these details at all only because it would be a
494+
// very nasty bug (so, important to resolve ASAP) if it ever did happen.
495+
'self-user missing from user list'));
496+
throw Exception("bad initial snapshot: self-user missing from user list");
497+
}
498+
499+
final realm = RealmStoreImpl(core: core, initialSnapshot: initialSnapshot);
486500
final users = UserStoreImpl(realm: realm, initialSnapshot: initialSnapshot,
487501
userMap: userMap);
488502
final channels = ChannelStoreImpl(users: users,

0 commit comments

Comments
 (0)