|
|
@ -74,6 +74,8 @@ import debounce from '../../helpers/schedulers/debounce'; |
|
|
|
import noop from '../../helpers/noop'; |
|
|
|
import noop from '../../helpers/noop'; |
|
|
|
import { putPreloader } from '../misc'; |
|
|
|
import { putPreloader } from '../misc'; |
|
|
|
import SetTransition from '../singleTransition'; |
|
|
|
import SetTransition from '../singleTransition'; |
|
|
|
|
|
|
|
import replaceContent from '../../helpers/dom/replaceContent'; |
|
|
|
|
|
|
|
import PeerTitle from '../peerTitle'; |
|
|
|
|
|
|
|
|
|
|
|
const RECORD_MIN_TIME = 500; |
|
|
|
const RECORD_MIN_TIME = 500; |
|
|
|
const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this group.'; |
|
|
|
const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this group.'; |
|
|
@ -108,11 +110,9 @@ export default class ChatInput { |
|
|
|
private sendMenu: SendMenu; |
|
|
|
private sendMenu: SendMenu; |
|
|
|
|
|
|
|
|
|
|
|
private replyElements: { |
|
|
|
private replyElements: { |
|
|
|
container?: HTMLElement, |
|
|
|
container: HTMLElement, |
|
|
|
cancelBtn?: HTMLButtonElement, |
|
|
|
cancelBtn: HTMLButtonElement |
|
|
|
titleEl?: HTMLElement, |
|
|
|
} = {} as any; |
|
|
|
subtitleEl?: HTMLElement |
|
|
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private willSendWebPage: any = null; |
|
|
|
private willSendWebPage: any = null; |
|
|
|
private forwardingMids: number[] = []; |
|
|
|
private forwardingMids: number[] = []; |
|
|
@ -292,12 +292,7 @@ export default class ChatInput { |
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.cancelBtn = ButtonIcon('close reply-cancel'); |
|
|
|
this.replyElements.cancelBtn = ButtonIcon('close reply-cancel'); |
|
|
|
|
|
|
|
|
|
|
|
const dac = new DivAndCaption('reply'); |
|
|
|
this.replyElements.container.append(this.replyElements.cancelBtn); |
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.titleEl = dac.title; |
|
|
|
|
|
|
|
this.replyElements.subtitleEl = dac.subtitle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.container.append(this.replyElements.cancelBtn, dac.container); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.newMessageWrapper = document.createElement('div'); |
|
|
|
this.newMessageWrapper = document.createElement('div'); |
|
|
|
this.newMessageWrapper.classList.add('new-message-wrapper'); |
|
|
|
this.newMessageWrapper.classList.add('new-message-wrapper'); |
|
|
@ -1691,9 +1686,8 @@ export default class ChatInput { |
|
|
|
// ! костыль
|
|
|
|
// ! костыль
|
|
|
|
const replyFragment = this.appMessagesManager.wrapMessageForReply(message, undefined, [message.mid]); |
|
|
|
const replyFragment = this.appMessagesManager.wrapMessageForReply(message, undefined, [message.mid]); |
|
|
|
this.setTopInfo('edit', f, 'Editing', undefined, input, message); |
|
|
|
this.setTopInfo('edit', f, 'Editing', undefined, input, message); |
|
|
|
const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle'); |
|
|
|
const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle') as HTMLElement; |
|
|
|
subtitleEl.textContent = ''; |
|
|
|
replaceContent(subtitleEl, replyFragment); |
|
|
|
subtitleEl.append(replyFragment); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.editMsgId = mid; |
|
|
|
this.editMsgId = mid; |
|
|
|
input = undefined; |
|
|
|
input = undefined; |
|
|
@ -1736,9 +1730,8 @@ export default class ChatInput { |
|
|
|
this.setTopInfo('forward', f, title); |
|
|
|
this.setTopInfo('forward', f, title); |
|
|
|
|
|
|
|
|
|
|
|
// ! костыль
|
|
|
|
// ! костыль
|
|
|
|
const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle'); |
|
|
|
const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle') as HTMLElement; |
|
|
|
subtitleEl.textContent = ''; |
|
|
|
replaceContent(subtitleEl, replyFragment); |
|
|
|
subtitleEl.append(replyFragment); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.setTopInfo('forward', f, title, mids.length + ' ' + (mids.length > 1 ? 'forwarded messages' : 'forwarded message')); |
|
|
|
this.setTopInfo('forward', f, title, mids.length + ' ' + (mids.length > 1 ? 'forwarded messages' : 'forwarded message')); |
|
|
|
} |
|
|
|
} |
|
|
@ -1753,7 +1746,11 @@ export default class ChatInput { |
|
|
|
public initMessageReply(mid: number) { |
|
|
|
public initMessageReply(mid: number) { |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
const f = () => { |
|
|
|
const f = () => { |
|
|
|
this.setTopInfo('reply', f, this.appPeersManager.getPeerTitle(message.fromId, true), message.message, undefined, message); |
|
|
|
const peerTitleEl = new PeerTitle({ |
|
|
|
|
|
|
|
peerId: message.fromId, |
|
|
|
|
|
|
|
dialog: false |
|
|
|
|
|
|
|
}).element; |
|
|
|
|
|
|
|
this.setTopInfo('reply', f, peerTitleEl, message.message, undefined, message); |
|
|
|
this.replyToMsgId = mid; |
|
|
|
this.replyToMsgId = mid; |
|
|
|
}; |
|
|
|
}; |
|
|
|
f(); |
|
|
|
f(); |
|
|
@ -1795,18 +1792,25 @@ export default class ChatInput { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public setTopInfo(type: ChatInputHelperType, callerFunc: () => void, title = '', subtitle = '', input?: string, message?: any) { |
|
|
|
public setTopInfo(type: ChatInputHelperType, |
|
|
|
|
|
|
|
callerFunc: () => void, |
|
|
|
|
|
|
|
title: HTMLElement | string = '', |
|
|
|
|
|
|
|
subtitle: HTMLElement | string = '', |
|
|
|
|
|
|
|
input?: string, |
|
|
|
|
|
|
|
message?: any) { |
|
|
|
if(type !== 'webpage') { |
|
|
|
if(type !== 'webpage') { |
|
|
|
this.clearHelper(type); |
|
|
|
this.clearHelper(type); |
|
|
|
this.helperType = type; |
|
|
|
this.helperType = type; |
|
|
|
this.helperFunc = callerFunc; |
|
|
|
this.helperFunc = callerFunc; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(this.replyElements.container.lastElementChild.tagName === 'DIV') { |
|
|
|
const replyParent = this.replyElements.container; |
|
|
|
this.replyElements.container.lastElementChild.remove(); |
|
|
|
if(replyParent.lastElementChild.tagName === 'DIV') { |
|
|
|
this.replyElements.container.append(wrapReply(title, subtitle, message)); |
|
|
|
replyParent.lastElementChild.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
replyParent.append(wrapReply(title, subtitle, message)); |
|
|
|
|
|
|
|
|
|
|
|
this.chat.container.classList.add('is-helper-active'); |
|
|
|
this.chat.container.classList.add('is-helper-active'); |
|
|
|
/* const scroll = appImManager.scrollable; |
|
|
|
/* const scroll = appImManager.scrollable; |
|
|
|
if(scroll.isScrolledDown && !scroll.scrollLocked && !appImManager.messagesQueuePromise && !appImManager.setPeerPromise) { |
|
|
|
if(scroll.isScrolledDown && !scroll.scrollLocked && !appImManager.messagesQueuePromise && !appImManager.setPeerPromise) { |
|
|
|