Skip to content

Commit edeb05d

Browse files
gnpricechrisbobbe
authored andcommitted
user [nfc]: Assert up front that self-user is present
This is already guaranteed by PerAccountStore.fromInitialSnapshot, the only caller of this constructor.
1 parent 90cb63a commit edeb05d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/model/user.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ class UserStoreImpl extends HasRealmStore with UserStore {
207207
}) : _users = userMap,
208208
_mutedUsers = Set.from(initialSnapshot.mutedUsers.map((item) => item.id)),
209209
_userStatuses = initialSnapshot.userStatuses.map((userId, change) =>
210-
MapEntry(userId, change.apply(UserStatus.zero)));
210+
MapEntry(userId, change.apply(UserStatus.zero))) {
211+
// Verify that [selfUser] will work.
212+
assert(_users.containsKey(selfUserId));
213+
}
211214

212215
static Map<int, User> userMapFromInitialSnapshot(InitialSnapshot initialSnapshot) {
213216
return Map.fromEntries(

0 commit comments

Comments
 (0)