forked from mirrors/linphone-iphone
Fix account deletion when network is disconnected and can delete account in the side view
This commit is contained in:
parent
2e5ba428a0
commit
33b07f1440
5 changed files with 49 additions and 7 deletions
|
|
@ -23,6 +23,7 @@
|
|||
import linphonesw
|
||||
import Combine
|
||||
import UniformTypeIdentifiers
|
||||
import Network
|
||||
|
||||
final class CoreContext: ObservableObject {
|
||||
|
||||
|
|
@ -39,6 +40,8 @@ final class CoreContext: ObservableObject {
|
|||
private var mIterateSuscription: AnyCancellable?
|
||||
private var mCoreSuscriptions = Set<AnyCancellable?>()
|
||||
|
||||
let monitor = NWPathMonitor()
|
||||
|
||||
private init() {
|
||||
do {
|
||||
try initialiseCore()
|
||||
|
|
@ -130,7 +133,7 @@ final class CoreContext: ObservableObject {
|
|||
if cbVal.status == Config.ConfiguringState.Successful {
|
||||
ToastViewModel.shared.toastMessage = "Successful"
|
||||
ToastViewModel.shared.displayToast = true
|
||||
}
|
||||
}
|
||||
/*
|
||||
else {
|
||||
ToastViewModel.shared.toastMessage = "Failed"
|
||||
|
|
@ -157,6 +160,21 @@ final class CoreContext: ObservableObject {
|
|||
self.loggedIn = false
|
||||
ToastViewModel.shared.toastMessage = "Registration failed"
|
||||
ToastViewModel.shared.displayToast = true
|
||||
|
||||
self.monitor.pathUpdateHandler = { path in
|
||||
if path.status == .satisfied {
|
||||
if cbVal.state != .Ok && cbVal.state != .Progress {
|
||||
let params = cbVal.account.params
|
||||
let clonedParams = params?.clone()
|
||||
clonedParams?.registerEnabled = false
|
||||
cbVal.account.params = clonedParams
|
||||
|
||||
cbVal.core.removeAccount(account: cbVal.account)
|
||||
cbVal.core.clearAccounts()
|
||||
cbVal.core.clearAllAuthInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -188,7 +206,7 @@ final class CoreContext: ObservableObject {
|
|||
|
||||
DispatchQueue.main.async {
|
||||
ToastViewModel.shared.toastMessage = "Success_send_logs"
|
||||
ToastViewModel.shared.displayToast = true
|
||||
ToastViewModel.shared.displayToast = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -364,6 +364,9 @@
|
|||
},
|
||||
"Log out" : {
|
||||
|
||||
},
|
||||
"Logout" : {
|
||||
|
||||
},
|
||||
"Logs cleared" : {
|
||||
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ class TelecomManager: ObservableObject {
|
|||
let oldRemoteVideo = self.remoteVideo
|
||||
self.remoteVideo = (core.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false)
|
||||
|
||||
if oldRemoteVideo != self.remoteVideo && self.remoteVideo {
|
||||
if self.remoteVideo && self.remoteVideo != oldRemoteVideo {
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
|
||||
} catch _ {
|
||||
|
|
|
|||
|
|
@ -71,16 +71,15 @@ struct SideMenu: View {
|
|||
clearLogs()
|
||||
self.menuClose()
|
||||
}
|
||||
/*
|
||||
Text("Logout")
|
||||
.frame(height: 40)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(Color.white)
|
||||
.onTapGesture {
|
||||
print("Logout")
|
||||
logout()
|
||||
self.menuClose()
|
||||
}
|
||||
*/
|
||||
}
|
||||
.frame(width: self.width - safeAreaInsets.leading)
|
||||
.background(Color.white)
|
||||
|
|
@ -110,4 +109,26 @@ struct SideMenu: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func logout() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
if core.defaultAccount != nil {
|
||||
let authInfo = core.defaultAccount!.findAuthInfo()
|
||||
if authInfo != nil {
|
||||
Log.info("$TAG Found auth info for account, removing it")
|
||||
core.removeAuthInfo(info: authInfo!)
|
||||
} else {
|
||||
Log.warn("$TAG Failed to find matching auth info for account")
|
||||
}
|
||||
|
||||
core.removeAccount(account: core.defaultAccount!)
|
||||
Log.info("$TAG Account has been removed")
|
||||
|
||||
DispatchQueue.main.async {
|
||||
coreContext.defaultAccount = nil
|
||||
coreContext.loggedIn = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ struct ToastView: View {
|
|||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
.foregroundStyle(toastViewModel.toastMessage.contains("Success") ? Color.greenSuccess500 : Color.redDanger500)
|
||||
|
||||
switch toastViewModel.toastMessage {
|
||||
|
|
@ -130,7 +129,8 @@ struct ToastView: View {
|
|||
toastViewModel.displayToast = false
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue