proper updating instead of setting things to nil
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user