mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Web Search improvements
This commit is contained in:
@@ -3816,9 +3816,9 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
||||
|
||||
configureLegacyAssetPicker(controller, account: strongSelf.account, peer: peer, presentWebSearch: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
let controller = WebSearchController(account: strongSelf.account, chatLocation: .peer(peer.id), configuration: searchBotsConfiguration, sendSelected: { (resuls, collection, editingContext) in
|
||||
let controller = WebSearchController(account: strongSelf.account, peer: peer, configuration: searchBotsConfiguration, mode: .media(completion: { results, editingContext in
|
||||
|
||||
})
|
||||
}))
|
||||
strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
})
|
||||
@@ -3842,7 +3842,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
||||
}
|
||||
|
||||
private func presentWebSearch(editingMessage: Bool) {
|
||||
guard let _ = self.presentationInterfaceState.renderedPeer?.peer else {
|
||||
guard let peer = self.presentationInterfaceState.renderedPeer?.peer else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3855,48 +3855,43 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] configuration in
|
||||
if let strongSelf = self {
|
||||
let controller = WebSearchController(account: strongSelf.account, chatLocation: strongSelf.chatLocation, configuration: configuration, sendSelected: { [weak self] ids, collection, editingContext in
|
||||
let controller = WebSearchController(account: strongSelf.account, peer: peer, configuration: configuration, mode: .media(completion: { [weak self] selectionState, editingState in
|
||||
if let strongSelf = self {
|
||||
var results: [ChatContextResult] = []
|
||||
for id in ids {
|
||||
var result: ChatContextResult?
|
||||
for r in collection.results {
|
||||
if r.id == id {
|
||||
result = r
|
||||
results.append(r)
|
||||
break
|
||||
}
|
||||
for item in selectionState.selectedItems() {
|
||||
if let item = item as? LegacyWebSearchItem {
|
||||
results.append(item.result)
|
||||
}
|
||||
}
|
||||
|
||||
if !results.isEmpty {
|
||||
var signals: [Any] = []
|
||||
for result in results {
|
||||
let editableItem = LegacyWebSearchItem(result: result, dimensions: CGSize(), thumbnailImage: .complete(), originalImage: .complete())
|
||||
if editingContext.adjustments(for: editableItem) != nil {
|
||||
if let imageSignal = editingContext.imageSignal(for: editableItem) {
|
||||
let editableItem = LegacyWebSearchItem(result: result)
|
||||
if editingState.adjustments(for: editableItem) != nil {
|
||||
if let imageSignal = editingState.imageSignal(for: editableItem) {
|
||||
let signal = imageSignal.map { image -> Any in
|
||||
if let image = image as? UIImage {
|
||||
let dict: [AnyHashable: Any] = [
|
||||
"type": "editedPhoto",
|
||||
"image": image
|
||||
]
|
||||
return legacyAssetPickerItemGenerator()(dict, nil, nil, nil)
|
||||
return legacyAssetPickerItemGenerator()(dict, nil, nil, nil) as Any
|
||||
} else {
|
||||
return SSignal.complete()
|
||||
}
|
||||
}
|
||||
signals.append(signal)
|
||||
signals.append(signal as Any)
|
||||
}
|
||||
} else {
|
||||
strongSelf.enqueueChatContextResult(collection, result, includeViaBot: false)
|
||||
strongSelf.enqueueChatContextResult(nil, result)
|
||||
}
|
||||
}
|
||||
|
||||
strongSelf.enqueueMediaMessages(signals: signals)
|
||||
}
|
||||
}
|
||||
})
|
||||
}))
|
||||
strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
})
|
||||
@@ -4177,11 +4172,11 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
||||
}))
|
||||
}
|
||||
|
||||
private func enqueueChatContextResult(_ results: ChatContextResultCollection, _ result: ChatContextResult, includeViaBot: Bool = true) {
|
||||
private func enqueueChatContextResult(_ results: ChatContextResultCollection?, _ result: ChatContextResult) {
|
||||
guard case let .peer(peerId) = self.chatLocation else {
|
||||
return
|
||||
}
|
||||
if let message = outgoingMessageWithChatContextResult(to: peerId, results: results, result: result, includeViaBot: includeViaBot), canSendMessagesToChat(self.presentationInterfaceState) {
|
||||
if let message = outgoingMessageWithChatContextResult(to: peerId, results: results, result: result), canSendMessagesToChat(self.presentationInterfaceState) {
|
||||
let replyMessageId = self.presentationInterfaceState.interfaceState.replyMessageId
|
||||
self.chatDisplayNode.setupSendActionOnViewUpdate({ [weak self] in
|
||||
if let strongSelf = self {
|
||||
|
||||
Reference in New Issue
Block a user