Open chats - only match leftovers

This commit is contained in:
Harold Hunt 2026-02-13 08:31:45 -05:00
parent 751d13a35e
commit 7a6184aef7

View file

@ -335,14 +335,19 @@ class DefaultIntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
|> castError(IntentContactsError.self)
|> mapToSignal { account -> Signal<[(String, TelegramUser)], IntentContactsError> in
if let account = account {
return combineLatest(
matchingCloudContacts(postbox: account.postbox, contacts: matchedContacts),
matchingOpenChatWithDeviceContacts(postbox: account.postbox, contacts: matchedContacts)
)
|> map { cloudContacts, openChatContacts in
var result = cloudContacts
result.append(contentsOf: openChatContacts)
return result
return matchingCloudContacts(postbox: account.postbox, contacts: matchedContacts)
|> mapToSignal { cloudContacts -> Signal<[(String, TelegramUser)], NoError> in
let matchedStableIds = Set(cloudContacts.map { $0.0 })
let unmatchedContacts = matchedContacts.filter { !matchedStableIds.contains($0.stableId) }
if unmatchedContacts.isEmpty {
return .single(cloudContacts)
}
return matchingOpenChatWithDeviceContacts(postbox: account.postbox, contacts: unmatchedContacts)
|> map { openChatContacts -> [(String, TelegramUser)] in
var result = cloudContacts
result.append(contentsOf: openChatContacts)
return result
}
}
|> castError(IntentContactsError.self)
} else {