Fixed message editing key shortcut

This commit is contained in:
Ilya Laktyushin 2019-07-11 17:29:50 +02:00
parent de0432d66a
commit c0d2c663ef

View File

@ -6843,24 +6843,23 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget,
} }
}) })
] ]
}
if let message = self.chatDisplayNode.historyNode.latestMessageInCurrentHistoryView(), !message.flags.contains(.Incoming) {
inputShortcuts.append(KeyShortcut(input: UIKeyInputUpArrow, action: { [weak self] in
if let strongSelf = self {
var canEdit = false var canEdit = false
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in self.updateChatPresentationInterfaceState(animated: false, interactive: false, { state in
if state.interfaceState.effectiveInputState.inputText.length == 0 && state.interfaceState.editMessage == nil { if state.interfaceState.effectiveInputState.inputText.length == 0 && state.interfaceState.editMessage == nil {
canEdit = true canEdit = true
} }
return state return state
}) })
if canEdit {
if canEdit, let message = self.chatDisplayNode.historyNode.firstMessageForEditInCurrentHistoryView() {
inputShortcuts.append(KeyShortcut(input: UIKeyInputUpArrow, action: { [weak self] in
if let strongSelf = self {
strongSelf.interfaceInteraction?.setupEditMessage(message.id) strongSelf.interfaceInteraction?.setupEditMessage(message.id)
} }
}
})) }))
} }
}
let otherShortcuts: [KeyShortcut] = [ let otherShortcuts: [KeyShortcut] = [
KeyShortcut(title: strings.KeyCommand_ScrollUp, input: UIKeyInputUpArrow, modifiers: [.shift], action: { [weak self] in KeyShortcut(title: strings.KeyCommand_ScrollUp, input: UIKeyInputUpArrow, modifiers: [.shift], action: { [weak self] in