setting up one way of doing alerts
This commit is contained in:
@@ -8,10 +8,29 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import AgoraRtcKit
|
import AgoraRtcKit
|
||||||
import Firebase
|
import Firebase
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
class ConvoViewModel: NSObject, ObservableObject {
|
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 selectedConvoId:String? = nil
|
||||||
@Published var connectionState: AgoraConnectionStateType?
|
@Published var connectionState: AgoraConnectionStateType?
|
||||||
|
@Published var error: Error?
|
||||||
|
|
||||||
let firestoreService = FirestoreService()
|
let firestoreService = FirestoreService()
|
||||||
private var db = Firestore.firestore()
|
private var db = Firestore.firestore()
|
||||||
@@ -464,3 +483,4 @@ extension ConvoViewModel: AgoraRtcEngineDelegate {
|
|||||||
self.selectedConvoId = nil
|
self.selectedConvoId = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,9 @@ struct CircleGridView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.animateLiveConvos = true
|
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
|
} // scrollview reader
|
||||||
}
|
}
|
||||||
@@ -485,7 +488,6 @@ extension CircleGridView {
|
|||||||
return
|
return
|
||||||
} // if I am in a convo, don't allow listening to a message or expanding details of a friend in my circle
|
} // 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() {
|
else if self.convoVM.isInCall() {
|
||||||
// TODO: show toast
|
|
||||||
print("can't select this friend as you are in a convo")
|
print("can't select this friend as you are in a convo")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user