testing relevancy score stuff

This commit is contained in:
talksik
2022-01-01 22:22:32 -08:00
parent 454601a13c
commit 4a74ecb7eb
2 changed files with 13 additions and 15 deletions
+12 -11
View File
@@ -28,7 +28,7 @@ class ConvoViewModel: NSObject, ObservableObject {
return self.selectedConvoId != nil return self.selectedConvoId != nil
} }
static var relevancyAcceptance = 0.6 static var relevancyAcceptance = 0.5
func initializeAgoraEngine() { func initializeAgoraEngine() {
self.agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: "c8dfd65deb5c4741bd564085627139d0", delegate: self) self.agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: "c8dfd65deb5c4741bd564085627139d0", delegate: self)
@@ -124,7 +124,7 @@ class ConvoViewModel: NSObject, ObservableObject {
} }
} }
let relevancyScore = Double(relevancyCount / convo.users.count) let relevancyScore = Double(relevancyCount) / Double(convo.users.count)
print("relevancy score: \(relevancyScore)") print("relevancy score: \(relevancyScore)")
if relevancyScore > Self.relevancyAcceptance { if relevancyScore > Self.relevancyAcceptance {
@@ -139,17 +139,12 @@ class ConvoViewModel: NSObject, ObservableObject {
} }
deinit { deinit {
// TODO: make sure that this gets fired if someone closes the app print("deiniting and cleaning up convo view model/agora services")
self.leaveConvo(destroyInstance: true)
// deinit the firestore listener // deinit the firestore listener
self.convosListener?.remove() self.convosListener?.remove()
// deinit the agora engine
print("deiniting and cleaning up convo view model/agora services")
AgoraRtcEngineKit.destroy()
self.leaveConvo()
} }
/** /**
@@ -262,7 +257,7 @@ class ConvoViewModel: NSObject, ObservableObject {
} }
// anyone can leave at any time // anyone can leave at any time
func leaveConvo() { func leaveConvo(destroyInstance: Bool = false) {
let userId = AuthSessionStore.getCurrentUserId() let userId = AuthSessionStore.getCurrentUserId()
if userId == nil { if userId == nil {
@@ -318,6 +313,12 @@ class ConvoViewModel: NSObject, ObservableObject {
self?.selectedConvoId = nil self?.selectedConvoId = nil
print("left convo officially in our db as well") print("left convo officially in our db as well")
// deinit the agora engine
if destroyInstance {
self?.destroyInstance()
}
} }
} }
} }
@@ -464,9 +464,6 @@ extension CircleGridView {
private func handleTap(gridItemIndex: Int, friendId: String) { private func handleTap(gridItemIndex: Int, friendId: String) {
print("tap gesture activated") print("tap gesture activated")
// TODO: make it deselect a currently selected user if that's the case
// if friend and I are online, and I am not in a convo, start convo immediately with them // if friend and I are online, and I am not in a convo, start convo immediately with them
if self.authSessionStore.relevantUsersDict[friendId]?.userStatus == .online if self.authSessionStore.relevantUsersDict[friendId]?.userStatus == .online
&& self.authSessionStore.user?.userStatus == .online && !self.convoVM.isInCall() { && self.authSessionStore.user?.userStatus == .online && !self.convoVM.isInCall() {