proper updating instead of setting things to nil

This commit is contained in:
talksik
2021-12-21 01:49:50 -08:00
parent 9c7fd76644
commit 1f468ca9af
2 changed files with 2 additions and 2 deletions
@@ -133,7 +133,7 @@ class FirestoreService {
else { // there seems to be something existing
for document in querySnapshot!.documents {
// update this userFriend that is existing
let _ = try? userFriendCollection.document(document.documentID).setData(from: userFriend)
let _ = try? userFriendCollection.document(document.documentID).setData(["isActive": true, "lastUpdatedTimestamp": self.getFirestoreServerTimestamp()], merge:true)
print("already existing, just updated")
completion(ServiceState.success("updated userfriend in firestore service"))
}
@@ -101,7 +101,7 @@ class ContactsViewModel : ObservableObject {
}
// setting timestamps to nil to make sure that new server timestamp is set
var userFriend = UserFriends(userId: userId, friendId: friendId, isActive: true, lastUpdatedTimestamp: nil, createdTimestamp: nil)
var userFriend = UserFriends(userId: userId, friendId: friendId, isActive: true, lastUpdatedTimestamp: nil)
self.firestoreService.createOrUpdateUserFriends(userFriend: userFriend) {[weak self] res in
completion(res)