working now with setting the right id and creating user properly

This commit is contained in:
talksik
2021-12-18 17:37:48 -08:00
parent 71f5aff78c
commit afe8cc4ad9
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import Foundation
import FirebaseFirestoreSwift
struct Messages: Identifiable, Codable {
@DocumentID var id: String?
@DocumentID var id: String? = UUID().uuidString
var senderId: String
var receiverId: String
+1 -1
View File
@@ -9,7 +9,7 @@ import Foundation
import FirebaseFirestoreSwift
struct User: Identifiable, Codable {
@DocumentID var id: String?
@DocumentID var id: String? = UUID().uuidString
var firstName: String?
var lastName: String?
var phoneNumber: String?
@@ -27,8 +27,9 @@ final class PhoneVerificationViewModel : ObservableObject {
print("user that was received from get: \(user?.id)")
if user == nil {// if empty, create user - 1 result set cost..prolly higher cost
let newOrExistingUser = User(id: userId, phoneNumber: phoneNumber)
firestoreService.createUser(user: newOrExistingUser)
print("creating new user with id: \(userId)")
let newUser = User(id: userId, phoneNumber: phoneNumber)
firestoreService.createUser(user: newUser)
} else { // if not, change last logged in value
// assign to nil so that server can fill it in
user!.lastLoggedInTimestamp = nil