mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various fixes
This commit is contained in:
@@ -473,15 +473,30 @@ func searchQuerySuggestionResultStateForChatInterfacePresentationState(_ chatPre
|
||||
signal = .single({ _ in return nil })
|
||||
}
|
||||
}
|
||||
|
||||
let participants = searchPeerMembers(context: context, peerId: peer.id, chatLocation: chatPresentationInterfaceState.chatLocation, query: query, scope: .memberSuggestion)
|
||||
|> map { peers -> (ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult? in
|
||||
|
||||
let participants = combineLatest(
|
||||
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)),
|
||||
searchPeerMembers(context: context, peerId: peer.id, chatLocation: chatPresentationInterfaceState.chatLocation, query: query, scope: .memberSuggestion)
|
||||
)
|
||||
|> map { accountPeer, peers -> (ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult? in
|
||||
let filteredPeers = peers
|
||||
var sortedPeers: [EnginePeer] = []
|
||||
sortedPeers.append(contentsOf: filteredPeers.sorted(by: { lhs, rhs in
|
||||
let result = lhs.indexName.stringRepresentation(lastNameFirst: true).compare(rhs.indexName.stringRepresentation(lastNameFirst: true))
|
||||
return result == .orderedAscending
|
||||
}))
|
||||
if let accountPeer {
|
||||
var hasOwnPeer = false
|
||||
for peer in sortedPeers {
|
||||
if peer.id == accountPeer.id {
|
||||
hasOwnPeer = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasOwnPeer {
|
||||
sortedPeers.append(accountPeer)
|
||||
}
|
||||
}
|
||||
return { _ in return .mentions(sortedPeers) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user