mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Extract forgotten Linphone objects that were being used in the main queue
This commit is contained in:
parent
290d842843
commit
dbb667fd9e
2 changed files with 30 additions and 25 deletions
|
|
@ -72,12 +72,15 @@ class ContactAvatarModel: ObservableObject {
|
|||
|
||||
func addSubscription() {
|
||||
friendSuscription = self.friend?.publisher?.onPresenceReceived?.postOnCoreQueue { (cbValue: (Friend)) in
|
||||
|
||||
let latestActivityTimestamp = cbValue.presenceModel?.latestActivityTimestamp ?? -1
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.presenceStatus = cbValue.consolidatedPresence
|
||||
if cbValue.consolidatedPresence == .Online || cbValue.consolidatedPresence == .Busy {
|
||||
if cbValue.consolidatedPresence == .Online || cbValue.presenceModel!.latestActivityTimestamp != -1 {
|
||||
if cbValue.consolidatedPresence == .Online || latestActivityTimestamp != -1 {
|
||||
self.lastPresenceInfo = cbValue.consolidatedPresence == .Online ?
|
||||
"Online" : self.getCallTime(startDate: cbValue.presenceModel!.latestActivityTimestamp)
|
||||
"Online" : self.getCallTime(startDate: latestActivityTimestamp)
|
||||
} else {
|
||||
self.lastPresenceInfo = "Away"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,36 +67,38 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
lastSearchSuggestions.append(searchResult)
|
||||
}
|
||||
}
|
||||
lastSearchSuggestions.sort(by: {
|
||||
$0.address!.asStringUriOnly() < $1.address!.asStringUriOnly()
|
||||
})
|
||||
let sortedLastSearch = lastSearchFriend.sorted(by: {
|
||||
$0.friend!.name!.lowercased().folding(options: .diacriticInsensitive, locale: .current)
|
||||
<
|
||||
$1.friend!.name!.lowercased().folding(options: .diacriticInsensitive, locale: .current)
|
||||
})
|
||||
|
||||
var addedAvatarListModel : [ContactAvatarModel] = []
|
||||
sortedLastSearch.forEach { searchResult in
|
||||
if searchResult.friend != nil {
|
||||
addedAvatarListModel.append(
|
||||
ContactAvatarModel(
|
||||
friend: searchResult.friend!,
|
||||
name: searchResult.friend?.name ?? "",
|
||||
address: searchResult.friend?.address?.clone()?.asStringUriOnly() ?? "",
|
||||
withPresence: true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.contactsManager.lastSearch = lastSearchFriend.sorted(by: {
|
||||
$0.friend!.name!.lowercased().folding(options: .diacriticInsensitive, locale: .current)
|
||||
<
|
||||
$1.friend!.name!.lowercased().folding(options: .diacriticInsensitive, locale: .current)
|
||||
})
|
||||
|
||||
self.contactsManager.lastSearchSuggestions = lastSearchSuggestions.sorted(by: {
|
||||
$0.address!.asStringUriOnly() < $1.address!.asStringUriOnly()
|
||||
})
|
||||
self.contactsManager.lastSearch = sortedLastSearch
|
||||
self.contactsManager.lastSearchSuggestions = lastSearchSuggestions
|
||||
|
||||
self.contactsManager.avatarListModel.forEach { contactAvatarModel in
|
||||
contactAvatarModel.removeAllSuscription()
|
||||
}
|
||||
|
||||
self.contactsManager.avatarListModel.removeAll()
|
||||
|
||||
self.contactsManager.lastSearch.forEach { searchResult in
|
||||
if searchResult.friend != nil {
|
||||
self.contactsManager.avatarListModel.append(
|
||||
ContactAvatarModel(
|
||||
friend: searchResult.friend!,
|
||||
name: searchResult.friend?.name ?? "",
|
||||
address: searchResult.friend?.address?.clone()?.asStringUriOnly() ?? "",
|
||||
withPresence: true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
self.contactsManager.avatarListModel += addedAvatarListModel
|
||||
|
||||
NotificationCenter.default.post(name: NSNotification.Name("ContactLoaded"), object: nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue