mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-17 20:08:31 +00:00
Fix contact search in MagicSearch
This commit is contained in:
parent
af5e25262c
commit
0217c167dc
14 changed files with 126 additions and 287 deletions
|
|
@ -104,7 +104,7 @@ final class ContactsManager: ObservableObject {
|
|||
print("\(#function) - failed to request access", error)
|
||||
self.addFriendListDelegate()
|
||||
self.addCoreDelegate(core: core)
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
return
|
||||
}
|
||||
if granted {
|
||||
|
|
@ -162,19 +162,19 @@ final class ContactsManager: ObservableObject {
|
|||
dispatchGroup.notify(queue: .main) {
|
||||
self.addFriendListDelegate()
|
||||
self.addCoreDelegate(core: core)
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
}
|
||||
} catch let error {
|
||||
print("\(#function) - Failed to enumerate contact", error)
|
||||
self.addFriendListDelegate()
|
||||
self.addCoreDelegate(core: core)
|
||||
MagicSearchSingleton.shared.searchForContactsWithoutCoreThread(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
}
|
||||
} else {
|
||||
print("\(#function) - access denied")
|
||||
self.addFriendListDelegate()
|
||||
self.addCoreDelegate(core: core)
|
||||
MagicSearchSingleton.shared.searchForContactsWithoutCoreThread(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ final class ContactsManager: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
MagicSearchSingleton.shared.searchForContactsWithoutCoreThread(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
},
|
||||
onPresenceReceived: { (friendList: FriendList, friends: [Friend?]) in
|
||||
Log.info("\(ContactsManager.TAG) FriendListDelegateStub onPresenceReceived \(friends.count)")
|
||||
|
|
|
|||
|
|
@ -1975,7 +1975,6 @@ struct CallView: View {
|
|||
if callViewModel.callsCounter < 2 {
|
||||
withAnimation {
|
||||
callViewModel.isTransferInsteadCall = true
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
|
||||
|
|
@ -2011,7 +2010,6 @@ struct CallView: View {
|
|||
VStack {
|
||||
Button {
|
||||
withAnimation {
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
|
||||
|
|
@ -2373,7 +2371,6 @@ struct CallView: View {
|
|||
if callViewModel.callsCounter < 2 {
|
||||
withAnimation {
|
||||
callViewModel.isTransferInsteadCall = true
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
|
||||
|
|
@ -2409,7 +2406,6 @@ struct CallView: View {
|
|||
VStack {
|
||||
Button {
|
||||
withAnimation {
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ struct EditContactFragment: View {
|
|||
withPresence: SharedMainViewModel.shared.displayedFriend?.withPresence
|
||||
)
|
||||
} else {
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
ContactsManager.shared.updateSubscriptionsLinphoneList()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,8 +231,7 @@ class ContactsListViewModel: ObservableObject {
|
|||
SharedMainViewModel.shared.displayedFriend!.friend!.remove()
|
||||
}
|
||||
|
||||
MagicSearchSingleton.shared.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -510,8 +510,7 @@ struct ContentView: View {
|
|||
sharedMainViewModel.displayedFriend = nil
|
||||
isMenuOpen = false
|
||||
magicSearch.allContact = true
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
magicSearch.searchForContacts()
|
||||
} label: {
|
||||
HStack {
|
||||
Text("contacts_list_filter_popup_see_all")
|
||||
|
|
@ -529,8 +528,7 @@ struct ContentView: View {
|
|||
sharedMainViewModel.displayedFriend = nil
|
||||
isMenuOpen = false
|
||||
magicSearch.allContact = false
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
magicSearch.searchForContacts()
|
||||
} label: {
|
||||
HStack {
|
||||
Text(String(format: String(localized: "contacts_list_filter_popup_see_linphone_only"), Bundle.main.displayName))
|
||||
|
|
@ -591,8 +589,7 @@ struct ContentView: View {
|
|||
|
||||
if sharedMainViewModel.indexView == 0 {
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
magicSearch.searchForContacts()
|
||||
} else if let historyListVM = historyListViewModel, sharedMainViewModel.indexView == 1 {
|
||||
historyListVM.resetFilterCallLogs()
|
||||
} else if let conversationsListVM = conversationsListViewModel, sharedMainViewModel.indexView == 2 {
|
||||
|
|
@ -637,8 +634,7 @@ struct ContentView: View {
|
|||
.onChange(of: text) { newValue in
|
||||
if sharedMainViewModel.indexView == 0 {
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
magicSearch.searchForContacts()
|
||||
} else if let historyListVM = historyListViewModel, sharedMainViewModel.indexView == 1 {
|
||||
if text.isEmpty {
|
||||
historyListVM.resetFilterCallLogs()
|
||||
|
|
@ -680,8 +676,7 @@ struct ContentView: View {
|
|||
.onChange(of: text) { newValue in
|
||||
if sharedMainViewModel.indexView == 0 {
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
magicSearch.searchForContacts()
|
||||
} else if let historyListVM = historyListViewModel, sharedMainViewModel.indexView == 1 {
|
||||
historyListVM.filterCallLogs(filter: text)
|
||||
} else if let conversationsListVM = conversationsListViewModel, sharedMainViewModel.indexView == 2 {
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ struct ConversationsView: View {
|
|||
withAnimation {
|
||||
isShowStartConversationFragment = true
|
||||
}
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
}
|
||||
} label: {
|
||||
Image("conversation")
|
||||
.renderingMode(.template)
|
||||
|
|
|
|||
|
|
@ -62,13 +62,9 @@ struct ConversationForwardMessageFragment: View {
|
|||
.padding(.top, 2)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
}
|
||||
|
||||
conversationForwardMessageViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
conversationForwardMessageViewModel.selectedMessage = nil
|
||||
withAnimation {
|
||||
|
|
@ -102,8 +98,8 @@ struct ConversationForwardMessageFragment: View {
|
|||
} else {
|
||||
conversationForwardMessageViewModel.filterConversations()
|
||||
}
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
|
||||
HStack {
|
||||
|
|
@ -121,9 +117,9 @@ struct ConversationForwardMessageFragment: View {
|
|||
if !conversationForwardMessageViewModel.searchField.isEmpty {
|
||||
Button(action: {
|
||||
conversationForwardMessageViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
conversationForwardMessageViewModel.resetFilterConversations()
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.searchForContacts()
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
|
|
@ -200,14 +196,10 @@ struct ConversationForwardMessageFragment: View {
|
|||
PopupLoadingView()
|
||||
.background(.black.opacity(0.65))
|
||||
.onDisappear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue
|
||||
)
|
||||
}
|
||||
|
||||
conversationForwardMessageViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
conversationForwardMessageViewModel.forwardMessage()
|
||||
|
||||
|
|
@ -228,18 +220,15 @@ struct ConversationForwardMessageFragment: View {
|
|||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.onAppear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
if !magicSearch.currentFilter.isEmpty {
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
}
|
||||
|
||||
conversationForwardMessageViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
conversationForwardMessageViewModel.selectedMessage = nil
|
||||
withAnimation {
|
||||
|
|
@ -286,31 +275,6 @@ struct ConversationForwardMessageFragment: View {
|
|||
HStack {
|
||||
if index < contactsManager.lastSearchSuggestions.count
|
||||
&& contactsManager.lastSearchSuggestions[index].address != nil {
|
||||
if contactsManager.lastSearchSuggestions[index].address!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.displayName!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address?.displayName ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else if contactsManager.lastSearchSuggestions[index].address!.username != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.username!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address!.username ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: String(contactsManager.lastSearchSuggestions[index].address!.asStringUriOnly().dropFirst(4)),
|
||||
lastName: ""))
|
||||
|
|
@ -322,7 +286,6 @@ struct ConversationForwardMessageFragment: View {
|
|||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
}
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
|
|
|
|||
|
|
@ -60,13 +60,9 @@ struct StartConversationFragment: View {
|
|||
.padding(.top, 2)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
}
|
||||
|
||||
startConversationViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
delayColorDismiss()
|
||||
withAnimation {
|
||||
isShowStartConversationFragment = false
|
||||
|
|
@ -94,8 +90,8 @@ struct StartConversationFragment: View {
|
|||
.focused($isSearchFieldFocused)
|
||||
.padding(.horizontal, 30)
|
||||
.onChange(of: startConversationViewModel.searchField) { newValue in
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
|
||||
HStack {
|
||||
|
|
@ -113,8 +109,8 @@ struct StartConversationFragment: View {
|
|||
if !startConversationViewModel.searchField.isEmpty {
|
||||
Button(action: {
|
||||
startConversationViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
|
|
@ -223,14 +219,9 @@ struct StartConversationFragment: View {
|
|||
PopupLoadingView()
|
||||
.background(.black.opacity(0.65))
|
||||
.onDisappear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue
|
||||
)
|
||||
}
|
||||
|
||||
startConversationViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
delayColorDismiss()
|
||||
|
||||
isShowStartConversationFragment = false
|
||||
|
|
@ -242,6 +233,12 @@ struct StartConversationFragment: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if !magicSearch.currentFilter.isEmpty {
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
|
|
@ -270,31 +267,6 @@ struct StartConversationFragment: View {
|
|||
HStack {
|
||||
if index < contactsManager.lastSearchSuggestions.count
|
||||
&& contactsManager.lastSearchSuggestions[index].address != nil {
|
||||
if contactsManager.lastSearchSuggestions[index].address!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.displayName!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address?.displayName ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else if contactsManager.lastSearchSuggestions[index].address!.username != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.username!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address!.username ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: String(contactsManager.lastSearchSuggestions[index].address!.asStringUriOnly().dropFirst(4)),
|
||||
lastName: ""))
|
||||
|
|
@ -306,7 +278,6 @@ struct StartConversationFragment: View {
|
|||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
}
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
|
|
|
|||
|
|
@ -455,18 +455,15 @@ struct DialerBottomSheet: View {
|
|||
if callViewModel.isTransferInsteadCall {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
callViewModel.resetCallView()
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
callViewModel.resetCallView()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
|
|
@ -477,18 +474,15 @@ struct DialerBottomSheet: View {
|
|||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
callViewModel.resetCallView()
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
callViewModel.resetCallView()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
|
|
|
|||
|
|
@ -93,19 +93,16 @@ struct StartCallFragment: View {
|
|||
.padding(.top, 2)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
resetCallView()
|
||||
|
||||
delayColorDismiss()
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
|
|
@ -133,8 +130,8 @@ struct StartCallFragment: View {
|
|||
.focused($isSearchFieldFocused)
|
||||
.padding(.horizontal, 30)
|
||||
.onChange(of: startCallViewModel.searchField) { newValue in
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
.simultaneousGesture(TapGesture().onEnded {
|
||||
showingDialer = false
|
||||
|
|
@ -177,8 +174,8 @@ struct StartCallFragment: View {
|
|||
} else {
|
||||
Button(action: {
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
|
|
@ -253,19 +250,17 @@ struct StartCallFragment: View {
|
|||
if callViewModel.isTransferInsteadCall {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
resetCallView()
|
||||
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
|
|
@ -275,19 +270,17 @@ struct StartCallFragment: View {
|
|||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
resetCallView()
|
||||
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
|
|
@ -336,6 +329,12 @@ struct StartCallFragment: View {
|
|||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.onAppear {
|
||||
if !magicSearch.currentFilter.isEmpty {
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable private func delayColor() async {
|
||||
|
|
@ -356,19 +355,17 @@ struct StartCallFragment: View {
|
|||
if callViewModel.isTransferInsteadCall {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
resetCallView()
|
||||
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
|
|
@ -380,19 +377,17 @@ struct StartCallFragment: View {
|
|||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilter = ""
|
||||
|
||||
magicSearch.searchForContacts()
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
resetCallView()
|
||||
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
|
|
@ -406,31 +401,6 @@ struct StartCallFragment: View {
|
|||
HStack {
|
||||
if index < contactsManager.lastSearchSuggestions.count
|
||||
&& contactsManager.lastSearchSuggestions[index].address != nil {
|
||||
if contactsManager.lastSearchSuggestions[index].address!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.displayName!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address?.displayName ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else if contactsManager.lastSearchSuggestions[index].address!.username != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: contactsManager.lastSearchSuggestions[index].address!.username!,
|
||||
lastName: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(contactsManager.lastSearchSuggestions[index].address!.username ?? "")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: String(contactsManager.lastSearchSuggestions[index].address!.asStringUriOnly().dropFirst(4)),
|
||||
lastName: ""))
|
||||
|
|
@ -442,7 +412,6 @@ struct StartCallFragment: View {
|
|||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
}
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@ struct HistoryView: View {
|
|||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
MagicSearchSingleton.shared.searchForSuggestions()
|
||||
}
|
||||
} label: {
|
||||
Image("phone-plus")
|
||||
.renderingMode(.template)
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@ struct AddParticipantsFragment: View {
|
|||
.focused($isSearchFieldFocused)
|
||||
.padding(.horizontal, 30)
|
||||
.onChange(of: addParticipantsViewModel.searchField) { newValue in
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = newValue
|
||||
magicSearch.searchForContacts()
|
||||
}.onAppear {
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
|
||||
HStack {
|
||||
|
|
@ -137,8 +137,8 @@ struct AddParticipantsFragment: View {
|
|||
if !addParticipantsViewModel.searchField.isEmpty {
|
||||
Button(action: {
|
||||
addParticipantsViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.searchForSuggestions()
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
isSearchFieldFocused = false
|
||||
}, label: {
|
||||
Image("x")
|
||||
|
|
@ -249,6 +249,9 @@ struct AddParticipantsFragment: View {
|
|||
withAnimation {
|
||||
confirmAddParticipantsFunc(addParticipantsViewModel.participantsToAdd)
|
||||
dismiss()
|
||||
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
} label: {
|
||||
Image("check")
|
||||
|
|
@ -264,6 +267,12 @@ struct AddParticipantsFragment: View {
|
|||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.onAppear {
|
||||
if !magicSearch.currentFilter.isEmpty {
|
||||
magicSearch.currentFilter = ""
|
||||
magicSearch.searchForContacts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var suggestionsList: some View {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ struct EditContactView: UIViewControllerRepresentable {
|
|||
contact: newContact,
|
||||
linphoneFriend: false,
|
||||
existingFriend: ContactsManager.shared.getFriendWithContact(contact: newContact)) {
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
MagicSearchSingleton.shared.searchForContacts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
var currentFilter: String = ""
|
||||
var previousFilter: String?
|
||||
|
||||
var currentFilterSuggestions: String = ""
|
||||
var previousFilterSuggestions: String?
|
||||
|
||||
var needUpdateLastSearchContacts = false
|
||||
|
||||
private var limitSearchToLinphoneAccounts = true
|
||||
|
|
@ -56,6 +53,7 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
self.magicSearch.limitedSearch = false
|
||||
|
||||
self.searchDelegate = MagicSearchDelegateStub(onSearchResultsReceived: { (magicSearch: MagicSearch) in
|
||||
print("[MagicSearchSingleton] [onSearchResultsReceived] Received search results")
|
||||
self.needUpdateLastSearchContacts = true
|
||||
|
||||
var lastSearchFriend: [SearchResult] = []
|
||||
|
|
@ -116,8 +114,8 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
func searchForContactsWithoutCoreThread(sourceFlags: Int) {
|
||||
if self.magicSearch != nil {
|
||||
func searchForContacts() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
var needResetCache = false
|
||||
|
||||
if let oldFilter = self.previousFilter {
|
||||
|
|
@ -125,6 +123,7 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
needResetCache = true
|
||||
}
|
||||
}
|
||||
|
||||
self.previousFilter = self.currentFilter
|
||||
|
||||
if needResetCache {
|
||||
|
|
@ -134,54 +133,6 @@ final class MagicSearchSingleton: ObservableObject {
|
|||
self.magicSearch.getContactsListAsync(
|
||||
filter: self.currentFilter,
|
||||
domain: self.allContact ? "" : self.domainDefaultAccount,
|
||||
sourceFlags: sourceFlags,
|
||||
aggregation: MagicSearch.Aggregation.Friend)
|
||||
}
|
||||
}
|
||||
|
||||
func searchForContacts(sourceFlags: Int) {
|
||||
if self.magicSearch != nil {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
var needResetCache = false
|
||||
|
||||
if let oldFilter = self.previousFilter {
|
||||
if oldFilter.count > self.currentFilter.count || oldFilter != self.currentFilter {
|
||||
needResetCache = true
|
||||
}
|
||||
}
|
||||
self.previousFilter = self.currentFilter
|
||||
|
||||
if needResetCache {
|
||||
self.magicSearch.resetSearchCache()
|
||||
}
|
||||
|
||||
self.magicSearch.getContactsListAsync(
|
||||
filter: self.currentFilter,
|
||||
domain: self.allContact ? "" : self.domainDefaultAccount,
|
||||
sourceFlags: sourceFlags,
|
||||
aggregation: MagicSearch.Aggregation.Friend)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func searchForSuggestions() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
var needResetCache = false
|
||||
|
||||
if let oldFilter = self.previousFilterSuggestions {
|
||||
if oldFilter.count > self.currentFilterSuggestions.count || oldFilter != self.currentFilterSuggestions {
|
||||
needResetCache = true
|
||||
}
|
||||
}
|
||||
self.previousFilterSuggestions = self.currentFilterSuggestions
|
||||
|
||||
if needResetCache {
|
||||
self.magicSearch.resetSearchCache()
|
||||
}
|
||||
|
||||
self.magicSearch.getContactsListAsync(
|
||||
filter: self.currentFilterSuggestions,
|
||||
domain: self.domainDefaultAccount,
|
||||
sourceFlags: MagicSearch.Source.All.rawValue,
|
||||
aggregation: MagicSearch.Aggregation.Friend)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue