one bug which breaks because of force unwrapping while someone logs out

the auth session store sets the user to nil while the circlegridview tries to still display stuff
This commit is contained in:
talksik
2021-12-21 19:30:30 -08:00
parent 1be4df1f99
commit ddb9a45f22
@@ -177,10 +177,12 @@ struct CircleGridView: View {
}
private func haveNewMessageFromFriend(friendDbId: String) -> Bool {
let userId = self.authSessionStore.user!.id // O(1) // currUser who is signed in
if let messagesRelatedToFriend = self.authSessionStore.friendMessagesDict[friendDbId] { // O(1)
return messagesRelatedToFriend.last?.receiverId == userId && messagesRelatedToFriend.last?.listenCount == 0
if self.authSessionStore.user != nil {
let userId = self.authSessionStore.user!.id // O(1) // currUser who is signed in
if let messagesRelatedToFriend = self.authSessionStore.friendMessagesDict[friendDbId] { // O(1)
return messagesRelatedToFriend.last?.receiverId == userId && messagesRelatedToFriend.last?.listenCount == 0
}
}
return false