Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin
2024-02-27 10:55:27 +04:00
50 changed files with 1447 additions and 444 deletions

View File

@@ -29,6 +29,7 @@ import ChatEntityKeyboardInputNode
import PremiumUI
import PremiumGiftAttachmentScreen
import TelegramCallsUI
import AutomaticBusinessMessageSetupScreen
import MediaEditorScreen
extension ChatControllerImpl {
@@ -132,8 +133,11 @@ extension ChatControllerImpl {
let buttons: Signal<([AttachmentButtonType], [AttachmentButtonType], AttachmentButtonType?), NoError>
if let peer = self.presentationInterfaceState.renderedPeer?.peer, !isScheduledMessages, !peer.isDeleted {
buttons = self.context.engine.messages.attachMenuBots()
|> map { attachMenuBots in
buttons = combineLatest(
self.context.engine.messages.attachMenuBots(),
self.context.engine.accountData.shortcutMessageList() |> take(1)
)
|> map { attachMenuBots, shortcutMessageList in
var buttons = availableButtons
var allButtons = availableButtons
var initialButton: AttachmentButtonType?
@@ -167,6 +171,19 @@ extension ChatControllerImpl {
allButtons.insert(button, at: 1)
}
if let user = peer as? TelegramUser, user.botInfo == nil {
if let index = buttons.firstIndex(where: { $0 == .location }) {
buttons.insert(.quickReply, at: index + 1)
} else {
buttons.append(.quickReply)
}
if let index = allButtons.firstIndex(where: { $0 == .location }) {
allButtons.insert(.quickReply, at: index + 1)
} else {
allButtons.append(.quickReply)
}
}
return (buttons, allButtons, initialButton)
}
} else {
@@ -603,6 +620,24 @@ extension ChatControllerImpl {
strongSelf.present(alertController, in: .window(.root))
}
}
case .quickReply:
let _ = (strongSelf.context.sharedContext.makeQuickReplySetupScreenInitialData(context: strongSelf.context)
|> take(1)
|> deliverOnMainQueue).start(next: { [weak strongSelf] initialData in
guard let strongSelf else {
return
}
let controller = QuickReplySetupScreen(context: strongSelf.context, initialData: initialData as! QuickReplySetupScreen.InitialData, mode: .select(completion: { [weak strongSelf] shortcutId in
guard let strongSelf else {
return
}
strongSelf.attachmentController?.dismiss(animated: true)
strongSelf.interfaceInteraction?.sendShortcut(shortcutId)
}))
completion(controller, controller.mediaPickerContext)
strongSelf.controllerNavigationDisposable.set(nil)
})
default:
break
}