|
|
@ -73,10 +73,10 @@ class ScrollPosition { |
|
|
|
//console.log('scrollPosition restore 2', this.node.scrollHeight, (this.node.scrollHeight
|
|
|
|
//console.log('scrollPosition restore 2', this.node.scrollHeight, (this.node.scrollHeight
|
|
|
|
//- this.previousScrollHeightMinusTop) + 'px', this.container);
|
|
|
|
//- this.previousScrollHeightMinusTop) + 'px', this.container);
|
|
|
|
|
|
|
|
|
|
|
|
//if(this.readyFor === 'up') {
|
|
|
|
if(this.readyFor === 'up' || appImManager.scroll.parentElement.classList.contains('scrolled-down')) { |
|
|
|
this.container.scrollTop = this.node.scrollHeight |
|
|
|
this.container.scrollTop = this.node.scrollHeight |
|
|
|
- this.previousScrollHeightMinusTop; |
|
|
|
- this.previousScrollHeightMinusTop; |
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 'down' doesn't need to be special cased unless the
|
|
|
|
// 'down' doesn't need to be special cased unless the
|
|
|
|
// content was flowing upwards, which would only happen
|
|
|
|
// content was flowing upwards, which would only happen
|
|
|
@ -122,7 +122,17 @@ class ChatInput { |
|
|
|
captionInput?: HTMLInputElement |
|
|
|
captionInput?: HTMLInputElement |
|
|
|
} = {}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public replyElements: { |
|
|
|
|
|
|
|
container?: HTMLDivElement, |
|
|
|
|
|
|
|
cancelBtn?: HTMLButtonElement, |
|
|
|
|
|
|
|
titleEl?: HTMLDivElement, |
|
|
|
|
|
|
|
subtitleEl?: HTMLDivElement |
|
|
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
public willSendWebPage: any = null; |
|
|
|
public willSendWebPage: any = null; |
|
|
|
|
|
|
|
public replyToMsgID = 0; |
|
|
|
|
|
|
|
public editMsgID = 0; |
|
|
|
|
|
|
|
public noWebPage = false; |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
this.toggleEmoticons = this.pageEl.querySelector('.toggle-emoticons') as HTMLButtonElement; |
|
|
|
this.toggleEmoticons = this.pageEl.querySelector('.toggle-emoticons') as HTMLButtonElement; |
|
|
@ -138,6 +148,11 @@ class ChatInput { |
|
|
|
this.attachMediaPopUp.mediaContainer = this.attachMediaPopUp.container.querySelector('.popup-photo') as HTMLDivElement; |
|
|
|
this.attachMediaPopUp.mediaContainer = this.attachMediaPopUp.container.querySelector('.popup-photo') as HTMLDivElement; |
|
|
|
this.attachMediaPopUp.captionInput = this.attachMediaPopUp.container.querySelector('input') as HTMLInputElement; |
|
|
|
this.attachMediaPopUp.captionInput = this.attachMediaPopUp.container.querySelector('input') as HTMLInputElement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.container = this.pageEl.querySelector('.reply-wrapper') as HTMLDivElement; |
|
|
|
|
|
|
|
this.replyElements.cancelBtn = this.replyElements.container.querySelector('.reply-cancel') as HTMLButtonElement; |
|
|
|
|
|
|
|
this.replyElements.titleEl = this.replyElements.container.querySelector('.reply-title') as HTMLDivElement; |
|
|
|
|
|
|
|
this.replyElements.subtitleEl = this.replyElements.container.querySelector('.reply-subtitle') as HTMLDivElement; |
|
|
|
|
|
|
|
|
|
|
|
this.messageInput.addEventListener('keydown', (e: KeyboardEvent) => { |
|
|
|
this.messageInput.addEventListener('keydown', (e: KeyboardEvent) => { |
|
|
|
if(e.key == 'Enter') { |
|
|
|
if(e.key == 'Enter') { |
|
|
|
/* if(e.ctrlKey || e.metaKey) { |
|
|
|
/* if(e.ctrlKey || e.metaKey) { |
|
|
@ -177,13 +192,12 @@ class ChatInput { |
|
|
|
}).then((webpage: any) => { |
|
|
|
}).then((webpage: any) => { |
|
|
|
appWebPagesManager.saveWebPage(webpage); |
|
|
|
appWebPagesManager.saveWebPage(webpage); |
|
|
|
if(this.lastUrl != url) return; |
|
|
|
if(this.lastUrl != url) return; |
|
|
|
//console.log(webpage);
|
|
|
|
console.log('got webpage: ', webpage); |
|
|
|
|
|
|
|
|
|
|
|
appImManager.replyElements.titleEl.innerHTML = RichTextProcessor.wrapEmojiText(webpage.site_name || webpage.title || ''); |
|
|
|
this.setTopInfo(webpage.site_name || webpage.title, webpage.description || webpage.url); |
|
|
|
appImManager.replyElements.subtitleEl.innerHTML = RichTextProcessor.wrapEmojiText(webpage.description || webpage.url || ''); |
|
|
|
|
|
|
|
appImManager.replyElements.container.classList.add('active'); |
|
|
|
this.replyToMsgID = 0; |
|
|
|
appImManager.replyToMsgID = 0; |
|
|
|
this.noWebPage = false; |
|
|
|
appImManager.noWebPage = false; |
|
|
|
|
|
|
|
this.willSendWebPage = webpage; |
|
|
|
this.willSendWebPage = webpage; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -408,6 +422,26 @@ class ChatInput { |
|
|
|
lottieLoader.checkAnimations(false, EMOTICONSSTICKERGROUP); |
|
|
|
lottieLoader.checkAnimations(false, EMOTICONSSTICKERGROUP); |
|
|
|
}, 0/* 200 */); |
|
|
|
}, 0/* 200 */); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.cancelBtn.addEventListener('click', () => { |
|
|
|
|
|
|
|
this.replyElements.container.classList.remove('active'); |
|
|
|
|
|
|
|
this.replyToMsgID = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.editMsgID) { |
|
|
|
|
|
|
|
if(this.willSendWebPage) { |
|
|
|
|
|
|
|
let message = appMessagesManager.getMessage(this.editMsgID); |
|
|
|
|
|
|
|
this.setTopInfo('Editing', message.message); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.editMsgID = 0; |
|
|
|
|
|
|
|
this.messageInput.innerHTML = ''; |
|
|
|
|
|
|
|
this.btnSend.classList.remove('tgico-send'); |
|
|
|
|
|
|
|
this.btnSend.classList.add('tgico-microphone2'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.noWebPage = true; |
|
|
|
|
|
|
|
this.willSendWebPage = null; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public serializeNodes(nodes: Node[]): string { |
|
|
|
public serializeNodes(nodes: Node[]): string { |
|
|
@ -430,14 +464,23 @@ class ChatInput { |
|
|
|
|
|
|
|
|
|
|
|
//return;
|
|
|
|
//return;
|
|
|
|
this.lastUrl = ''; |
|
|
|
this.lastUrl = ''; |
|
|
|
appMessagesManager.sendText(appImManager.peerID, str, { |
|
|
|
|
|
|
|
replyToMsgID: appImManager.replyToMsgID == 0 ? undefined : appImManager.replyToMsgID, |
|
|
|
if(this.editMsgID) { |
|
|
|
noWebPage: appImManager.noWebPage, |
|
|
|
appMessagesManager.editMessage(this.editMsgID, str, { |
|
|
|
webPage: this.willSendWebPage |
|
|
|
noWebPage: this.noWebPage |
|
|
|
}); |
|
|
|
}); |
|
|
|
appImManager.replyToMsgID = 0; |
|
|
|
} else { |
|
|
|
appImManager.noWebPage = false; |
|
|
|
appMessagesManager.sendText(appImManager.peerID, str, { |
|
|
|
appImManager.replyElements.container.classList.remove('active'); |
|
|
|
replyToMsgID: this.replyToMsgID == 0 ? undefined : this.replyToMsgID, |
|
|
|
|
|
|
|
noWebPage: this.noWebPage, |
|
|
|
|
|
|
|
webPage: this.willSendWebPage |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.editMsgID = 0; |
|
|
|
|
|
|
|
this.replyToMsgID = 0; |
|
|
|
|
|
|
|
this.noWebPage = false; |
|
|
|
|
|
|
|
this.replyElements.container.classList.remove('active'); |
|
|
|
appImManager.scroll.scrollTop = appImManager.scroll.scrollHeight; |
|
|
|
appImManager.scroll.scrollTop = appImManager.scroll.scrollHeight; |
|
|
|
this.willSendWebPage = null; |
|
|
|
this.willSendWebPage = null; |
|
|
|
this.messageInput.innerText = ''; |
|
|
|
this.messageInput.innerText = ''; |
|
|
@ -445,6 +488,23 @@ class ChatInput { |
|
|
|
this.btnSend.classList.remove('tgico-send'); |
|
|
|
this.btnSend.classList.remove('tgico-send'); |
|
|
|
this.btnSend.classList.add('tgico-microphone2'); |
|
|
|
this.btnSend.classList.add('tgico-microphone2'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public setTopInfo(title: string, subtitle: string, input?: string) { |
|
|
|
|
|
|
|
//appImManager.scrollPosition.prepareFor('down');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.titleEl.innerHTML = title ? RichTextProcessor.wrapEmojiText(title) : ''; |
|
|
|
|
|
|
|
this.replyElements.subtitleEl.innerHTML = subtitle ? RichTextProcessor.wrapEmojiText(subtitle) : ''; |
|
|
|
|
|
|
|
this.replyElements.container.classList.add('active'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(input !== undefined) { |
|
|
|
|
|
|
|
this.messageInput.innerHTML = input ? RichTextProcessor.wrapRichText(input) : ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.btnSend.classList.remove('tgico-microphone2'); |
|
|
|
|
|
|
|
this.btnSend.classList.add('tgico-send'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//appImManager.scrollPosition.restore();
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export class AppImManager { |
|
|
|
export class AppImManager { |
|
|
@ -508,13 +568,6 @@ export class AppImManager { |
|
|
|
private contextMenuEdit = this.contextMenu.querySelector('.menu-edit') as HTMLDivElement; |
|
|
|
private contextMenuEdit = this.contextMenu.querySelector('.menu-edit') as HTMLDivElement; |
|
|
|
private contextMenuMsgID: number; |
|
|
|
private contextMenuMsgID: number; |
|
|
|
|
|
|
|
|
|
|
|
public replyElements: { |
|
|
|
|
|
|
|
container?: HTMLDivElement, |
|
|
|
|
|
|
|
cancelBtn?: HTMLButtonElement, |
|
|
|
|
|
|
|
titleEl?: HTMLDivElement, |
|
|
|
|
|
|
|
subtitleEl?: HTMLDivElement |
|
|
|
|
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private popupDeleteMessage: { |
|
|
|
private popupDeleteMessage: { |
|
|
|
popupEl?: HTMLDivElement, |
|
|
|
popupEl?: HTMLDivElement, |
|
|
|
deleteBothBtn?: HTMLButtonElement, |
|
|
|
deleteBothBtn?: HTMLButtonElement, |
|
|
@ -522,9 +575,6 @@ export class AppImManager { |
|
|
|
cancelBtn?: HTMLButtonElement |
|
|
|
cancelBtn?: HTMLButtonElement |
|
|
|
} = {}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
|
|
|
|
public replyToMsgID = 0; |
|
|
|
|
|
|
|
public noWebPage = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
this.log = logger('IM'); |
|
|
|
this.log = logger('IM'); |
|
|
|
|
|
|
|
|
|
|
@ -537,11 +587,6 @@ export class AppImManager { |
|
|
|
this.popupDeleteMessage.deleteMeBtn = this.popupDeleteMessage.popupEl.querySelector('.popup-delete-me') as HTMLButtonElement; |
|
|
|
this.popupDeleteMessage.deleteMeBtn = this.popupDeleteMessage.popupEl.querySelector('.popup-delete-me') as HTMLButtonElement; |
|
|
|
this.popupDeleteMessage.cancelBtn = this.popupDeleteMessage.popupEl.querySelector('.popup-close') as HTMLButtonElement; |
|
|
|
this.popupDeleteMessage.cancelBtn = this.popupDeleteMessage.popupEl.querySelector('.popup-close') as HTMLButtonElement; |
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.container = this.pageEl.querySelector('.reply-wrapper') as HTMLDivElement; |
|
|
|
|
|
|
|
this.replyElements.cancelBtn = this.replyElements.container.querySelector('.reply-cancel') as HTMLButtonElement; |
|
|
|
|
|
|
|
this.replyElements.titleEl = this.replyElements.container.querySelector('.reply-title') as HTMLDivElement; |
|
|
|
|
|
|
|
this.replyElements.subtitleEl = this.replyElements.container.querySelector('.reply-subtitle') as HTMLDivElement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apiManager.getUserID().then((id) => { |
|
|
|
apiManager.getUserID().then((id) => { |
|
|
|
this.myID = id; |
|
|
|
this.myID = id; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -931,11 +976,16 @@ export class AppImManager { |
|
|
|
|
|
|
|
|
|
|
|
this.contextMenu.querySelector('.menu-reply').addEventListener('click', () => { |
|
|
|
this.contextMenu.querySelector('.menu-reply').addEventListener('click', () => { |
|
|
|
let message = appMessagesManager.getMessage(this.contextMenuMsgID); |
|
|
|
let message = appMessagesManager.getMessage(this.contextMenuMsgID); |
|
|
|
let title = appPeersManager.getPeerTitle(message.fromID); |
|
|
|
this.chatInputC.setTopInfo(appPeersManager.getPeerTitle(message.fromID), message.message); |
|
|
|
this.replyElements.titleEl.innerHTML = title; |
|
|
|
this.chatInputC.replyToMsgID = this.contextMenuMsgID; |
|
|
|
this.replyElements.subtitleEl.innerHTML = message.message ? RichTextProcessor.wrapEmojiText(message.message) : ''; |
|
|
|
this.chatInputC.editMsgID = 0; |
|
|
|
this.replyElements.container.classList.add('active'); |
|
|
|
}); |
|
|
|
this.replyToMsgID = this.contextMenuMsgID; |
|
|
|
|
|
|
|
|
|
|
|
this.contextMenuEdit.addEventListener('click', () => { |
|
|
|
|
|
|
|
let message = appMessagesManager.getMessage(this.contextMenuMsgID); |
|
|
|
|
|
|
|
this.chatInputC.setTopInfo('Editing', message.message, message.message); |
|
|
|
|
|
|
|
this.chatInputC.replyToMsgID = 0; |
|
|
|
|
|
|
|
this.chatInputC.editMsgID = this.contextMenuMsgID; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.contextMenuPin.addEventListener('click', () => { |
|
|
|
this.contextMenuPin.addEventListener('click', () => { |
|
|
@ -949,13 +999,6 @@ export class AppImManager { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.replyElements.cancelBtn.addEventListener('click', () => { |
|
|
|
|
|
|
|
this.replyElements.container.classList.remove('active'); |
|
|
|
|
|
|
|
this.replyToMsgID = 0; |
|
|
|
|
|
|
|
this.noWebPage = true; |
|
|
|
|
|
|
|
this.chatInputC.willSendWebPage = null; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.popupDeleteMessage.deleteBothBtn.addEventListener('click', () => { |
|
|
|
this.popupDeleteMessage.deleteBothBtn.addEventListener('click', () => { |
|
|
|
this.deleteMessages(true); |
|
|
|
this.deleteMessages(true); |
|
|
|
this.popupDeleteMessage.cancelBtn.click(); |
|
|
|
this.popupDeleteMessage.cancelBtn.click(); |
|
|
@ -1322,7 +1365,7 @@ export class AppImManager { |
|
|
|
|
|
|
|
|
|
|
|
// clear input
|
|
|
|
// clear input
|
|
|
|
this.chatInputC.messageInput.innerHTML = ''; |
|
|
|
this.chatInputC.messageInput.innerHTML = ''; |
|
|
|
this.replyElements.cancelBtn.click(); |
|
|
|
this.chatInputC.replyElements.cancelBtn.click(); |
|
|
|
|
|
|
|
|
|
|
|
// clear messages
|
|
|
|
// clear messages
|
|
|
|
this.chatInner.innerHTML = ''; |
|
|
|
this.chatInner.innerHTML = ''; |
|
|
@ -1894,7 +1937,8 @@ export class AppImManager { |
|
|
|
let originalText = ''; |
|
|
|
let originalText = ''; |
|
|
|
if(originalMessage.message) { |
|
|
|
if(originalMessage.message) { |
|
|
|
originalText = RichTextProcessor.wrapRichText(originalMessage.message, { |
|
|
|
originalText = RichTextProcessor.wrapRichText(originalMessage.message, { |
|
|
|
entities: originalMessage.totalEntities |
|
|
|
entities: originalMessage.totalEntities, |
|
|
|
|
|
|
|
noLinebreaks: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1945,7 +1989,7 @@ export class AppImManager { |
|
|
|
nameDiv.style.color = appPeersManager.getPeerColorByID(message.fromID, false); |
|
|
|
nameDiv.style.color = appPeersManager.getPeerColorByID(message.fromID, false); |
|
|
|
nameDiv.dataset.peerID = message.fromID; |
|
|
|
nameDiv.dataset.peerID = message.fromID; |
|
|
|
bubble.append(nameDiv); |
|
|
|
bubble.append(nameDiv); |
|
|
|
} else if(!message.reply_to_mid) { |
|
|
|
} else /* if(!message.reply_to_mid) */ { |
|
|
|
bubble.classList.add('hide-name'); |
|
|
|
bubble.classList.add('hide-name'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1975,6 +2019,8 @@ export class AppImManager { |
|
|
|
|
|
|
|
|
|
|
|
bubble.append(avatarDiv); |
|
|
|
bubble.append(avatarDiv); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
bubble.classList.add('hide-name'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(message._ == 'messageService') { |
|
|
|
if(message._ == 'messageService') { |
|
|
@ -2211,10 +2257,10 @@ export class AppImManager { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if(!this.muted) { |
|
|
|
if(!this.muted) { |
|
|
|
settings.flags |= 2 << 1; |
|
|
|
settings.flags |= 1 << 2; |
|
|
|
settings.mute_until = 2147483646; |
|
|
|
settings.mute_until = 2147483646; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
settings.flags |= 1 << 1; |
|
|
|
settings.flags |= 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
apiManager.invokeApi('account.updateNotifySettings', { |
|
|
|
apiManager.invokeApi('account.updateNotifySettings', { |
|
|
|