fixing logic to make sure there are no duplicates in the friends arr

This commit is contained in:
talksik
2021-12-28 16:49:19 -08:00
parent b60f7e77b3
commit 5d143ea2e8
+7 -2
View File
@@ -288,8 +288,13 @@ extension AuthSessionStore {
if updatedReturnedUser != nil {
DispatchQueue.main.async {
self.relevantUsersDict[userFriend!.friendId] = updatedReturnedUser!
self.friendsArr.append(userFriend!.friendId)
// update current friendsArr if the friend is already there
if let indexFriend = self.friendsArr.firstIndex(of: userFriend!.friendId) {
print("friend already in the friends arr, just needed to update the relevantusersdict")
} else { // new friend not in array
self.friendsArr.append(userFriend!.friendId)
}
self.objectWillChange.send()