|
|
@ -10,8 +10,11 @@ import { ReplyMarkup } from "../../layer"; |
|
|
|
import RichTextProcessor from "../../lib/richtextprocessor"; |
|
|
|
import RichTextProcessor from "../../lib/richtextprocessor"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import { safeAssign } from "../../helpers/object"; |
|
|
|
import { safeAssign } from "../../helpers/object"; |
|
|
|
import ListenerSetter from "../../helpers/listenerSetter"; |
|
|
|
import ListenerSetter, { Listener } from "../../helpers/listenerSetter"; |
|
|
|
import findUpClassName from "../../helpers/dom/findUpClassName"; |
|
|
|
import findUpClassName from "../../helpers/dom/findUpClassName"; |
|
|
|
|
|
|
|
import { isTouchSupported } from "../../helpers/touchSupport"; |
|
|
|
|
|
|
|
import findUpAsChild from "../../helpers/dom/findUpAsChild"; |
|
|
|
|
|
|
|
import { cancelEvent } from "../../helpers/dom/cancelEvent"; |
|
|
|
|
|
|
|
|
|
|
|
export default class ReplyKeyboard extends DropdownHover { |
|
|
|
export default class ReplyKeyboard extends DropdownHover { |
|
|
|
private static BASE_CLASS = 'reply-keyboard'; |
|
|
|
private static BASE_CLASS = 'reply-keyboard'; |
|
|
@ -20,6 +23,7 @@ export default class ReplyKeyboard extends DropdownHover { |
|
|
|
private appMessagesManager: AppMessagesManager; |
|
|
|
private appMessagesManager: AppMessagesManager; |
|
|
|
private btnHover: HTMLElement; |
|
|
|
private btnHover: HTMLElement; |
|
|
|
private peerId: number; |
|
|
|
private peerId: number; |
|
|
|
|
|
|
|
private touchListener: Listener<HTMLElement>; |
|
|
|
|
|
|
|
|
|
|
|
constructor(options: { |
|
|
|
constructor(options: { |
|
|
|
listenerSetter: ListenerSetter, |
|
|
|
listenerSetter: ListenerSetter, |
|
|
@ -49,6 +53,13 @@ export default class ReplyKeyboard extends DropdownHover { |
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(this, 'open', () => { |
|
|
|
this.listenerSetter.add(this, 'open', () => { |
|
|
|
this.render(); |
|
|
|
this.render(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isTouchSupported) { |
|
|
|
|
|
|
|
this.touchListener = this.listenerSetter.add(document.body, 'touchstart', this.onBodyTouchStart, {passive: false, capture: true}); |
|
|
|
|
|
|
|
this.listenerSetter.add(this, 'close', () => { |
|
|
|
|
|
|
|
this.listenerSetter.remove(this.touchListener); |
|
|
|
|
|
|
|
}, {once: true}); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(this.element, 'click', (e) => { |
|
|
|
this.listenerSetter.add(this.element, 'click', (e) => { |
|
|
@ -64,6 +75,14 @@ export default class ReplyKeyboard extends DropdownHover { |
|
|
|
return super.init(); |
|
|
|
return super.init(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private onBodyTouchStart = (e: TouchEvent) => { |
|
|
|
|
|
|
|
const target = e.touches[0].target as HTMLElement; |
|
|
|
|
|
|
|
if(!findUpAsChild(target, this.element) && target !== this.btnHover) { |
|
|
|
|
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
this.toggle(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private getReplyMarkup(): ReplyMarkup { |
|
|
|
private getReplyMarkup(): ReplyMarkup { |
|
|
|
return this.appMessagesManager.getHistoryStorage(this.peerId).reply_markup ?? { |
|
|
|
return this.appMessagesManager.getHistoryStorage(this.peerId).reply_markup ?? { |
|
|
|
_: 'replyKeyboardHide' |
|
|
|
_: 'replyKeyboardHide' |
|
|
|