setting up one way of doing alerts
This commit is contained in:
@@ -8,10 +8,29 @@
|
||||
import Foundation
|
||||
import AgoraRtcKit
|
||||
import Firebase
|
||||
import SwiftUI
|
||||
|
||||
class ConvoViewModel: NSObject, ObservableObject {
|
||||
enum Error: Identifiable {
|
||||
var id: Self { self }
|
||||
|
||||
case notAuthenticated
|
||||
case maxLimitUsers
|
||||
case convoNotFound
|
||||
|
||||
var alert: Alert {
|
||||
switch self {
|
||||
case .notAuthenticated:
|
||||
return Alert(title: Text("Not Authenticated!"))
|
||||
default:
|
||||
return Alert(title: Text("There was a problem"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published var selectedConvoId:String? = nil
|
||||
@Published var connectionState: AgoraConnectionStateType?
|
||||
@Published var error: Error?
|
||||
|
||||
let firestoreService = FirestoreService()
|
||||
private var db = Firestore.firestore()
|
||||
@@ -464,3 +483,4 @@ extension ConvoViewModel: AgoraRtcEngineDelegate {
|
||||
self.selectedConvoId = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -337,6 +337,9 @@ struct CircleGridView: View {
|
||||
}
|
||||
|
||||
self.animateLiveConvos = true
|
||||
}// univseral alert TODO: move to inner circle view and use this pattern for all view models
|
||||
.alert(item: self.$convoVM.error) {error in
|
||||
error.alert
|
||||
}
|
||||
} // scrollview reader
|
||||
}
|
||||
@@ -485,7 +488,6 @@ extension CircleGridView {
|
||||
return
|
||||
} // if I am in a convo, don't allow listening to a message or expanding details of a friend in my circle
|
||||
else if self.convoVM.isInCall() {
|
||||
// TODO: show toast
|
||||
print("can't select this friend as you are in a convo")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user