fixing some problems and adding more fixes to overall flow
This commit is contained in:
@@ -104,16 +104,17 @@ struct AddBasicInfoView: View {
|
||||
|
||||
// button to save information
|
||||
Button {
|
||||
print("attempting to save information")
|
||||
var updatedUser = self.authSessionStore.user
|
||||
updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex]
|
||||
updatedUser?.nickname = self.nickname
|
||||
|
||||
if updatedUser != nil {
|
||||
self.addInfoViewModel.updateUser(currUser: updatedUser!)
|
||||
}
|
||||
print("attempting to save information \(updatedUser)")
|
||||
|
||||
self.navigationStack.push(InnerCircleView())
|
||||
if updatedUser != nil {
|
||||
self.addInfoViewModel.updateUser(currUser: updatedUser!) {
|
||||
self.navigationStack.push(InnerCircleView())
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Text("Save")
|
||||
.fontWeight(.heavy)
|
||||
|
||||
@@ -20,7 +20,7 @@ class AddBasicInfoViewModel : ObservableObject {
|
||||
|
||||
// - get user data current data
|
||||
// - save user selections
|
||||
func updateUser(currUser: User) {
|
||||
func updateUser(currUser: User, completion: @escaping () -> Void) {
|
||||
// validations
|
||||
// make sure nickname is less than 25 characters for now
|
||||
|
||||
@@ -28,14 +28,17 @@ class AddBasicInfoViewModel : ObservableObject {
|
||||
|
||||
if currUser.nickname == nil || currUser.avatar == nil {
|
||||
self.state = .failed("Please make sure to select avatar and nickname 🙏")
|
||||
completion()
|
||||
return
|
||||
}
|
||||
if currUser.nickname!.count > 25 {
|
||||
self.state = .failed("Please use a simpler nickname less than 25 characters 🙏")
|
||||
completion()
|
||||
return
|
||||
}
|
||||
if !Avatars.avatarSystemNames.contains(currUser.avatar!) {
|
||||
self.state = .failed("Invalid avatar selected!")
|
||||
completion()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,6 +52,8 @@ class AddBasicInfoViewModel : ObservableObject {
|
||||
case .error(let error):
|
||||
self.state = .failed(error.description)
|
||||
}
|
||||
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user