getting dispatch to main thread as close to the listener as possible to allow quickest change
This commit is contained in:
@@ -28,6 +28,7 @@ class FirestoreService {
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
guard let updatedOrNewUser = try? document.data(as: User.self)
|
||||
else {
|
||||
completion(nil)
|
||||
@@ -38,6 +39,7 @@ class FirestoreService {
|
||||
completion(updatedOrNewUser)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getUser(userId: String, completion: @escaping((_ user: User?) -> ())) {
|
||||
let docRef = db.collection(Collection.users.rawValue).document(userId)
|
||||
|
||||
@@ -136,13 +136,11 @@ final class AuthSessionStore: ObservableObject, SessionStore {
|
||||
|
||||
// when we have a user get signed in, we can activate the listener for fetching the user's data to keep our auth session store always up to date for all of the ui
|
||||
self.firestoreService.getUserRealtime(userId: uid) {[weak self] realtimeUpdatedUser in
|
||||
DispatchQueue.main.async {
|
||||
if realtimeUpdatedUser != nil {
|
||||
print("up to date user: \(realtimeUpdatedUser)")
|
||||
self?.user = realtimeUpdatedUser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: listener for getting user's sent and received messages
|
||||
|
||||
|
||||
Reference in New Issue
Block a user