mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix callbacks
This commit is contained in:
parent
3bb0d06787
commit
035149bd47
5 changed files with 52 additions and 67 deletions
|
|
@ -20,6 +20,7 @@
|
|||
// swiftlint:disable large_tuple
|
||||
import linphonesw
|
||||
import Combine
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
final class CoreContext: ObservableObject {
|
||||
|
||||
|
|
@ -156,6 +157,20 @@ final class CoreContext: ObservableObject {
|
|||
TelecomManager.shared.onCallStateChanged(core: cbVal.core, call: cbVal.call, state: cbVal.state, message: cbVal.message)
|
||||
}
|
||||
|
||||
self.mCore.publisher?.onLogCollectionUploadStateChanged?.postOnMainQueue { (cbValue: (_: Core, _: Core.LogCollectionUploadState, info: String)) in
|
||||
print("publisherpublisher onLogCollectionUploadStateChanged")
|
||||
|
||||
if cbValue.info.starts(with: "https") {
|
||||
UIPasteboard.general.setValue(
|
||||
cbValue.info,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
self.mIteratePublisher = Timer.publish(every: 0.02, on: .main, in: .common)
|
||||
.autoconnect()
|
||||
.receive(on: coreQueue)
|
||||
|
|
|
|||
|
|
@ -217,6 +217,9 @@
|
|||
},
|
||||
"Contacts" : {
|
||||
|
||||
},
|
||||
"Content" : {
|
||||
|
||||
},
|
||||
"Continue" : {
|
||||
|
||||
|
|
@ -486,6 +489,9 @@
|
|||
},
|
||||
"This contact will be deleted definitively." : {
|
||||
|
||||
},
|
||||
"Title" : {
|
||||
|
||||
},
|
||||
"TLS" : {
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,24 @@ class ContactAvatarModel: ObservableObject {
|
|||
}
|
||||
|
||||
func addDelegate() {
|
||||
|
||||
/*
|
||||
self.friend?.publisher?.onPresenceReceived?.postOnMainQueue { (cbValue: (Friend)) in
|
||||
print("publisherpublisher onLogCollectionUploadStateChanged \(cbValue.address?.asStringUriOnly())")
|
||||
|
||||
self.presenceStatus = cbValue.consolidatedPresence
|
||||
if cbValue.consolidatedPresence == .Online || cbValue.consolidatedPresence == .Busy {
|
||||
if cbValue.consolidatedPresence == .Online || cbValue.presenceModel!.latestActivityTimestamp != -1 {
|
||||
self.lastPresenceInfo = cbValue.consolidatedPresence == .Online ? "Online" : self.getCallTime(startDate: cbValue.presenceModel!.latestActivityTimestamp)
|
||||
} else {
|
||||
self.lastPresenceInfo = "Away"
|
||||
}
|
||||
} else {
|
||||
self.lastPresenceInfo = ""
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
let newFriendDelegate = FriendDelegateStub(
|
||||
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
|
||||
DispatchQueue.main.sync {
|
||||
|
|
@ -80,6 +98,7 @@ class ContactAvatarModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
friendDelegate = newFriendDelegate
|
||||
if friendDelegate != nil {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ struct SideMenu: View {
|
|||
|
||||
@ObservedObject private var coreContext = CoreContext.shared
|
||||
|
||||
@State private var coreDelegate: CoreDelegate?
|
||||
|
||||
let width: CGFloat
|
||||
let isOpen: Bool
|
||||
let menuClose: () -> Void
|
||||
|
|
@ -75,37 +73,6 @@ struct SideMenu: View {
|
|||
func sendLogs() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
core.uploadLogCollection()
|
||||
|
||||
let newCoreDelegate = CoreDelegateStub(
|
||||
onLogCollectionUploadStateChanged: { core, logCollectionUploadState, logString in
|
||||
|
||||
if logString.starts(with: "https") {
|
||||
UIPasteboard.general.setValue(
|
||||
logString,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
|
||||
removeAllDelegate()
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
coreDelegate = newCoreDelegate
|
||||
if coreDelegate != nil {
|
||||
core.addDelegate(delegate: coreDelegate!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func removeAllDelegate() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
if coreDelegate != nil {
|
||||
core.removeDelegate(delegate: coreDelegate!)
|
||||
coreDelegate = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,9 @@ class HistoryListViewModel: ObservableObject {
|
|||
@Published var callLogs: [CallLog] = []
|
||||
var callLogsTmp: [CallLog] = []
|
||||
|
||||
@Published private var coreDelegate: CoreDelegate?
|
||||
|
||||
var callLogsAddressToDelete = ""
|
||||
|
||||
init() {
|
||||
removeAllDelegate()
|
||||
computeCallLogsList()
|
||||
}
|
||||
|
||||
|
|
@ -49,29 +46,20 @@ class HistoryListViewModel: ObservableObject {
|
|||
self.callLogsTmp.append(log)
|
||||
}
|
||||
}
|
||||
/*
|
||||
DispatchQueue.main.async {
|
||||
self.coreDelegate = CoreDelegateStub(
|
||||
onCallLogUpdated: { (_: Core, _: CallLog) -> Void in
|
||||
DispatchQueue.main.sync {
|
||||
let account = core.defaultAccount
|
||||
let logs = account != nil ? account!.callLogs : core.callLogs
|
||||
|
||||
self.callLogs.removeAll()
|
||||
self.callLogsTmp.removeAll()
|
||||
|
||||
logs.forEach { log in
|
||||
self.callLogs.append(log)
|
||||
self.callLogsTmp.append(log)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
if self.coreDelegate != nil {
|
||||
core.addDelegate(delegate: self.coreDelegate!)
|
||||
|
||||
core.publisher?.onCallLogUpdated?.postOnMainQueue { (_: (_: Core, _: CallLog)) in
|
||||
print("publisherpublisher onCallLogUpdated")
|
||||
let account = core.defaultAccount
|
||||
let logs = account != nil ? account!.callLogs : core.callLogs
|
||||
|
||||
self.callLogs.removeAll()
|
||||
self.callLogsTmp.removeAll()
|
||||
|
||||
logs.forEach { log in
|
||||
self.callLogs.append(log)
|
||||
self.callLogsTmp.append(log)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,14 +198,4 @@ class HistoryListViewModel: ObservableObject {
|
|||
let indexTmp = self.callLogsTmp.firstIndex(where: {$0.callId == callLog.callId})
|
||||
self.callLogsTmp.remove(at: indexTmp!)
|
||||
}
|
||||
|
||||
func removeAllDelegate() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
if self.coreDelegate != nil {
|
||||
core.removeDelegate(delegate: self.coreDelegate!)
|
||||
self.coreDelegate = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue