|
|
@ -35,7 +35,6 @@ import LazyLoadQueue from "../lazyLoadQueue"; |
|
|
|
import { AppChatsManager } from "../../lib/appManagers/appChatsManager"; |
|
|
|
import { AppChatsManager } from "../../lib/appManagers/appChatsManager"; |
|
|
|
import Chat from "./chat"; |
|
|
|
import Chat from "./chat"; |
|
|
|
import ListenerSetter from "../../helpers/listenerSetter"; |
|
|
|
import ListenerSetter from "../../helpers/listenerSetter"; |
|
|
|
import { pause } from "../../helpers/schedulers"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const IGNORE_ACTIONS = ['messageActionHistoryClear']; |
|
|
|
const IGNORE_ACTIONS = ['messageActionHistoryClear']; |
|
|
|
|
|
|
|
|
|
|
@ -148,7 +147,7 @@ export default class ChatBubbles { |
|
|
|
let bubble = this.bubbles[mid]; |
|
|
|
let bubble = this.bubbles[mid]; |
|
|
|
if(!bubble) return; |
|
|
|
if(!bubble) return; |
|
|
|
|
|
|
|
|
|
|
|
let message = appMessagesManager.getMessage(mid); |
|
|
|
let message = this.chat.getMessage(mid); |
|
|
|
//this.log('history_update', this.bubbles[mid], mid, message);
|
|
|
|
//this.log('history_update', this.bubbles[mid], mid, message);
|
|
|
|
|
|
|
|
|
|
|
|
let dateMessage = this.getDateContainerByMessage(message, false); |
|
|
|
let dateMessage = this.getDateContainerByMessage(message, false); |
|
|
@ -196,7 +195,7 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
this.log('message_sent', e.detail); |
|
|
|
this.log('message_sent', e.detail); |
|
|
|
|
|
|
|
|
|
|
|
const message = this.appMessagesManager.getMessage(mid); |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
|
|
|
|
|
|
|
|
appSidebarRight.sharedMediaTab.renderNewMessages(message.peerId, [mid]); |
|
|
|
appSidebarRight.sharedMediaTab.renderNewMessages(message.peerId, [mid]); |
|
|
|
|
|
|
|
|
|
|
@ -282,7 +281,7 @@ export default class ChatBubbles { |
|
|
|
if(!this.bubbles[maxId]) return; |
|
|
|
if(!this.bubbles[maxId]) return; |
|
|
|
|
|
|
|
|
|
|
|
const renderMaxId = getObjectKeysAndSort(appMessagesManager.groupedMessagesStorage[groupId], 'asc').pop(); |
|
|
|
const renderMaxId = getObjectKeysAndSort(appMessagesManager.groupedMessagesStorage[groupId], 'asc').pop(); |
|
|
|
this.renderMessage(appMessagesManager.getMessage(renderMaxId), true, false, this.bubbles[maxId], false); |
|
|
|
this.renderMessage(this.chat.getMessage(renderMaxId), true, false, this.bubbles[maxId], false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(rootScope, 'messages_downloaded', (e) => { |
|
|
|
this.listenerSetter.add(rootScope, 'messages_downloaded', (e) => { |
|
|
@ -301,9 +300,9 @@ export default class ChatBubbles { |
|
|
|
const bubble = this.bubbles[mid]; |
|
|
|
const bubble = this.bubbles[mid]; |
|
|
|
if(!bubble) return; |
|
|
|
if(!bubble) return; |
|
|
|
|
|
|
|
|
|
|
|
const message = appMessagesManager.getMessage(mid); |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
|
|
|
|
|
|
|
|
const repliedMessage = appMessagesManager.getMessage(replyMid); |
|
|
|
const repliedMessage = this.chat.getMessage(replyMid); |
|
|
|
if(repliedMessage.deleted) { // чтобы не пыталось бесконечно загрузить удалённое сообщение
|
|
|
|
if(repliedMessage.deleted) { // чтобы не пыталось бесконечно загрузить удалённое сообщение
|
|
|
|
delete message.reply_to_mid; // WARNING!
|
|
|
|
delete message.reply_to_mid; // WARNING!
|
|
|
|
} |
|
|
|
} |
|
|
@ -321,10 +320,14 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(this.bubblesContainer, 'click', this.onBubblesClick/* , {capture: true, passive: false} */); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public constructPeerHelpers() { |
|
|
|
this.listenerSetter.add(rootScope, 'dialog_unread', (e) => { |
|
|
|
this.listenerSetter.add(rootScope, 'dialog_unread', (e) => { |
|
|
|
const info = e.detail; |
|
|
|
const info = e.detail; |
|
|
|
|
|
|
|
|
|
|
|
const dialog = appMessagesManager.getDialogByPeerId(info.peerId)[0]; |
|
|
|
const dialog = this.appMessagesManager.getDialogByPeerId(info.peerId)[0]; |
|
|
|
if(dialog?.peerId == this.peerId) { |
|
|
|
if(dialog?.peerId == this.peerId) { |
|
|
|
this.chat.input.setUnreadCount(); |
|
|
|
this.chat.input.setUnreadCount(); |
|
|
|
this.updateUnreadByDialog(dialog); |
|
|
|
this.updateUnreadByDialog(dialog); |
|
|
@ -347,8 +350,6 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(this.bubblesContainer, 'click', this.onBubblesClick/* , {capture: true, passive: false} */); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.stickyIntersector = new StickyIntersector(this.scrollable.container, (stuck, target) => { |
|
|
|
this.stickyIntersector = new StickyIntersector(this.scrollable.container, (stuck, target) => { |
|
|
|
for(const timestamp in this.dateMessages) { |
|
|
|
for(const timestamp in this.dateMessages) { |
|
|
|
const dateMessage = this.dateMessages[timestamp]; |
|
|
|
const dateMessage = this.dateMessages[timestamp]; |
|
|
@ -395,9 +396,9 @@ export default class ChatBubbles { |
|
|
|
} */ |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
//appMessagesManager.readMessages(readed);
|
|
|
|
//appMessagesManager.readMessages(readed);
|
|
|
|
/* false && */ appMessagesManager.readHistory(this.peerId, max).catch((err: any) => { |
|
|
|
/* false && */ this.appMessagesManager.readHistory(this.peerId, max).catch((err: any) => { |
|
|
|
this.log.error('readHistory err:', err); |
|
|
|
this.log.error('readHistory err:', err); |
|
|
|
appMessagesManager.readHistory(this.peerId, max); |
|
|
|
this.appMessagesManager.readHistory(this.peerId, max); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -406,7 +407,6 @@ export default class ChatBubbles { |
|
|
|
public constructPinnedHelpers() { |
|
|
|
public constructPinnedHelpers() { |
|
|
|
this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { |
|
|
|
this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { |
|
|
|
const {peerId, mids, pinned} = e.detail; |
|
|
|
const {peerId, mids, pinned} = e.detail; |
|
|
|
|
|
|
|
|
|
|
|
if(peerId !== this.peerId) return; |
|
|
|
if(peerId !== this.peerId) return; |
|
|
|
|
|
|
|
|
|
|
|
if(mids) { |
|
|
|
if(mids) { |
|
|
@ -417,6 +417,15 @@ export default class ChatBubbles { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public constructScheduledHelpers() { |
|
|
|
|
|
|
|
this.listenerSetter.add(rootScope, 'scheduled_delete', (e) => { |
|
|
|
|
|
|
|
const {peerId, mids} = e.detail; |
|
|
|
|
|
|
|
if(peerId !== this.peerId) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.deleteMessagesByIds(mids); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onBubblesClick = (e: Event) => { |
|
|
|
public onBubblesClick = (e: Event) => { |
|
|
|
let target = e.target as HTMLElement; |
|
|
|
let target = e.target as HTMLElement; |
|
|
|
let bubble: HTMLElement = null; |
|
|
|
let bubble: HTMLElement = null; |
|
|
@ -479,7 +488,7 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
if(bubble.classList.contains('sticker') && target.parentElement.classList.contains('attachment')) { |
|
|
|
if(bubble.classList.contains('sticker') && target.parentElement.classList.contains('attachment')) { |
|
|
|
const messageId = +bubble.dataset.mid; |
|
|
|
const messageId = +bubble.dataset.mid; |
|
|
|
const message = this.appMessagesManager.getMessage(messageId); |
|
|
|
const message = this.chat.getMessage(messageId); |
|
|
|
|
|
|
|
|
|
|
|
const doc = message.media?.document; |
|
|
|
const doc = message.media?.document; |
|
|
|
|
|
|
|
|
|
|
@ -495,7 +504,7 @@ export default class ChatBubbles { |
|
|
|
|| isVideoComponentElement |
|
|
|
|| isVideoComponentElement |
|
|
|
|| (target.tagName == 'VIDEO' && !bubble.classList.contains('round'))) { |
|
|
|
|| (target.tagName == 'VIDEO' && !bubble.classList.contains('round'))) { |
|
|
|
let messageId = +findUpClassName(target, 'album-item')?.dataset.mid || +bubble.dataset.mid; |
|
|
|
let messageId = +findUpClassName(target, 'album-item')?.dataset.mid || +bubble.dataset.mid; |
|
|
|
let message = this.appMessagesManager.getMessage(messageId); |
|
|
|
let message = this.chat.getMessage(messageId); |
|
|
|
if(!message) { |
|
|
|
if(!message) { |
|
|
|
this.log.warn('no message by messageId:', messageId); |
|
|
|
this.log.warn('no message by messageId:', messageId); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -505,7 +514,7 @@ export default class ChatBubbles { |
|
|
|
let ids = Object.keys(this.bubbles).map(k => +k).filter(id => { |
|
|
|
let ids = Object.keys(this.bubbles).map(k => +k).filter(id => { |
|
|
|
//if(!this.scrollable.visibleElements.find(e => e.element == this.bubbles[id])) return false;
|
|
|
|
//if(!this.scrollable.visibleElements.find(e => e.element == this.bubbles[id])) return false;
|
|
|
|
|
|
|
|
|
|
|
|
let message = this.appMessagesManager.getMessage(id); |
|
|
|
let message = this.chat.getMessage(id); |
|
|
|
|
|
|
|
|
|
|
|
return message.media && (message.media.photo || (message.media.document && (message.media.document.type == 'video' || message.media.document.type == 'gif')) || (message.media.webpage && (message.media.webpage.document || message.media.webpage.photo))); |
|
|
|
return message.media && (message.media.photo || (message.media.document && (message.media.document.type == 'video' || message.media.document.type == 'gif')) || (message.media.webpage && (message.media.webpage.document || message.media.webpage.photo))); |
|
|
|
}).sort((a, b) => a - b); |
|
|
|
}).sort((a, b) => a - b); |
|
|
@ -548,9 +557,9 @@ export default class ChatBubbles { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(['IMG', 'DIV', "AVATAR-ELEMENT", 'A'].indexOf(target.tagName) === -1) target = findUpTag(target, 'DIV'); |
|
|
|
if(['IMG', 'DIV', "AVATAR-ELEMENT"/* , 'A' */].indexOf(target.tagName) === -1) target = findUpTag(target, 'DIV'); |
|
|
|
|
|
|
|
|
|
|
|
if(target.tagName == 'DIV' || target.tagName == "AVATAR-ELEMENT" || target.tagName == 'A') { |
|
|
|
if(target.tagName == 'DIV' || target.tagName == "AVATAR-ELEMENT"/* || target.tagName == 'A' */) { |
|
|
|
if(target.classList.contains('goto-original')) { |
|
|
|
if(target.classList.contains('goto-original')) { |
|
|
|
const savedFrom = bubble.dataset.savedFrom; |
|
|
|
const savedFrom = bubble.dataset.savedFrom; |
|
|
|
const splitted = savedFrom.split('_'); |
|
|
|
const splitted = savedFrom.split('_'); |
|
|
@ -561,25 +570,10 @@ export default class ChatBubbles { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else if(target.classList.contains('forward')) { |
|
|
|
} else if(target.classList.contains('forward')) { |
|
|
|
const mid = +bubble.dataset.mid; |
|
|
|
const mid = +bubble.dataset.mid; |
|
|
|
new PopupForward([mid]); |
|
|
|
new PopupForward(this.peerId, [mid]); |
|
|
|
//appSidebarRight.forwardTab.open([mid]);
|
|
|
|
//appSidebarRight.forwardTab.open([mid]);
|
|
|
|
return; |
|
|
|
return; |
|
|
|
}/* else if(target.classList.contains('follow')) { |
|
|
|
} else if(target.classList.contains('name')) { |
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
const savedFrom = target.dataset.follow; |
|
|
|
|
|
|
|
const splitted = savedFrom.split('_'); |
|
|
|
|
|
|
|
this.chat.appImManager.setInnerPeer(+splitted[0], splitted.length > 1 ? +splitted[1] : undefined); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else if(target.classList.contains('mention')) { |
|
|
|
|
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
const username = target.innerText; |
|
|
|
|
|
|
|
this.appUsersManager.resolveUsername(username.slice(1)).then(peer => { |
|
|
|
|
|
|
|
this.chat.appImManager.setInnerPeer(peer._ == 'user' ? peer.id : -peer.id); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} */ else if(target.classList.contains('name')) { |
|
|
|
|
|
|
|
const peerId = +target.dataset.peerId; |
|
|
|
const peerId = +target.dataset.peerId; |
|
|
|
|
|
|
|
|
|
|
|
if(peerId) { |
|
|
|
if(peerId) { |
|
|
@ -628,7 +622,7 @@ export default class ChatBubbles { |
|
|
|
const rect = bubble.getBoundingClientRect(); |
|
|
|
const rect = bubble.getBoundingClientRect(); |
|
|
|
bad = (this.appPhotosManager.windowH / 2) > rect.top; |
|
|
|
bad = (this.appPhotosManager.windowH / 2) > rect.top; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const message = this.appMessagesManager.getMessage(mid); |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
if(!message.deleted) { |
|
|
|
if(!message.deleted) { |
|
|
|
bad = false; |
|
|
|
bad = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -661,7 +655,7 @@ export default class ChatBubbles { |
|
|
|
if(this.bubbles[mid]) { |
|
|
|
if(this.bubbles[mid]) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
bubble: this.bubbles[mid], |
|
|
|
bubble: this.bubbles[mid], |
|
|
|
message: this.appMessagesManager.getMessage(+mid) |
|
|
|
message: this.chat.getMessage(+mid) |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -674,7 +668,7 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public getMountedBubble(mid: number) { |
|
|
|
public getMountedBubble(mid: number) { |
|
|
|
const message = this.appMessagesManager.getMessage(mid); |
|
|
|
const message = this.chat.getMessage(mid); |
|
|
|
|
|
|
|
|
|
|
|
if(message.grouped_id && this.appMessagesManager.getMidsByAlbum(message.grouped_id).length > 1) { |
|
|
|
if(message.grouped_id && this.appMessagesManager.getMidsByAlbum(message.grouped_id).length > 1) { |
|
|
|
const a = this.getGroupedBubble(message.grouped_id); |
|
|
|
const a = this.getGroupedBubble(message.grouped_id); |
|
|
@ -837,7 +831,9 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.bubbleGroups.removeBubble(bubble, mid); |
|
|
|
this.bubbleGroups.removeBubble(bubble, mid); |
|
|
|
this.unreadedObserver.unobserve(bubble); |
|
|
|
if(this.unreadedObserver) { |
|
|
|
|
|
|
|
this.unreadedObserver.unobserve(bubble); |
|
|
|
|
|
|
|
} |
|
|
|
//this.unreaded.findAndSplice(mid => mid == id);
|
|
|
|
//this.unreaded.findAndSplice(mid => mid == id);
|
|
|
|
bubble.remove(); |
|
|
|
bubble.remove(); |
|
|
|
//bubble.remove();
|
|
|
|
//bubble.remove();
|
|
|
@ -854,7 +850,7 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msgIds.forEach((msgId: number) => { |
|
|
|
msgIds.forEach((msgId: number) => { |
|
|
|
let message = this.appMessagesManager.getMessage(msgId); |
|
|
|
let message = this.chat.getMessage(msgId); |
|
|
|
|
|
|
|
|
|
|
|
/////////this.log('got new message to append:', message);
|
|
|
|
/////////this.log('got new message to append:', message);
|
|
|
|
|
|
|
|
|
|
|
@ -937,7 +933,9 @@ export default class ChatBubbles { |
|
|
|
this.chatInner.append(container); |
|
|
|
this.chatInner.append(container); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.stickyIntersector.observeStickyHeaderChanges(container); |
|
|
|
if(this.stickyIntersector) { |
|
|
|
|
|
|
|
this.stickyIntersector.observeStickyHeaderChanges(container); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.dateMessages[dateTimestamp]; |
|
|
|
return this.dateMessages[dateTimestamp]; |
|
|
@ -951,12 +949,12 @@ export default class ChatBubbles { |
|
|
|
this.listenerSetter.removeAll(); |
|
|
|
this.listenerSetter.removeAll(); |
|
|
|
|
|
|
|
|
|
|
|
this.lazyLoadQueue.clear(); |
|
|
|
this.lazyLoadQueue.clear(); |
|
|
|
this.unreadedObserver.disconnect(); |
|
|
|
this.unreadedObserver && this.unreadedObserver.disconnect(); |
|
|
|
this.stickyIntersector.disconnect(); |
|
|
|
this.stickyIntersector && this.stickyIntersector.disconnect(); |
|
|
|
|
|
|
|
|
|
|
|
delete this.lazyLoadQueue; |
|
|
|
delete this.lazyLoadQueue; |
|
|
|
delete this.unreadedObserver; |
|
|
|
this.unreadedObserver && delete this.unreadedObserver; |
|
|
|
delete this.stickyIntersector; |
|
|
|
this.stickyIntersector && delete this.stickyIntersector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public cleanup(bubblesToo = false) { |
|
|
|
public cleanup(bubblesToo = false) { |
|
|
@ -990,10 +988,14 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
this.getHistoryTopPromise = this.getHistoryBottomPromise = undefined; |
|
|
|
this.getHistoryTopPromise = this.getHistoryBottomPromise = undefined; |
|
|
|
|
|
|
|
|
|
|
|
this.stickyIntersector.disconnect(); |
|
|
|
if(this.stickyIntersector) { |
|
|
|
|
|
|
|
this.stickyIntersector.disconnect(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.unreadedObserver.disconnect(); |
|
|
|
if(this.unreadedObserver) { |
|
|
|
this.unreaded.length = 0; |
|
|
|
this.unreadedObserver.disconnect(); |
|
|
|
|
|
|
|
this.unreaded.length = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.loadedTopTimes = this.loadedBottomTimes = 0; |
|
|
|
this.loadedTopTimes = this.loadedBottomTimes = 0; |
|
|
|
|
|
|
|
|
|
|
@ -1350,7 +1352,7 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
if(!our && !message.pFlags.out) { |
|
|
|
if(!our && !message.pFlags.out) { |
|
|
|
//this.log('not our message', message, message.pFlags.unread);
|
|
|
|
//this.log('not our message', message, message.pFlags.unread);
|
|
|
|
if(message.pFlags.unread) { |
|
|
|
if(message.pFlags.unread && this.unreadedObserver) { |
|
|
|
this.unreadedObserver.observe(bubble); |
|
|
|
this.unreadedObserver.observe(bubble); |
|
|
|
if(!this.unreaded.indexOf(message.mid)) { |
|
|
|
if(!this.unreaded.indexOf(message.mid)) { |
|
|
|
this.unreaded.push(message.mid); |
|
|
|
this.unreaded.push(message.mid); |
|
|
@ -1539,7 +1541,7 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const button = row.buttons[column]; |
|
|
|
const button = row.buttons[column]; |
|
|
|
this.appInlineBotsManager.callbackButtonClick(message.mid, button); |
|
|
|
this.appInlineBotsManager.callbackButtonClick(this.peerId, message.mid, button); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const offset = rows.length * 45 + 'px'; |
|
|
|
const offset = rows.length * 45 + 'px'; |
|
|
@ -1585,7 +1587,8 @@ export default class ChatBubbles { |
|
|
|
groupId: '' + message.id, |
|
|
|
groupId: '' + message.id, |
|
|
|
attachmentDiv, |
|
|
|
attachmentDiv, |
|
|
|
uploading: true, |
|
|
|
uploading: true, |
|
|
|
isOut: true |
|
|
|
isOut: true, |
|
|
|
|
|
|
|
chat: this.chat |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
@ -1645,7 +1648,8 @@ export default class ChatBubbles { |
|
|
|
albumMustBeRenderedFull, |
|
|
|
albumMustBeRenderedFull, |
|
|
|
message, |
|
|
|
message, |
|
|
|
bubble, |
|
|
|
bubble, |
|
|
|
messageDiv |
|
|
|
messageDiv, |
|
|
|
|
|
|
|
chat: this.chat |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if(newNameContainer) { |
|
|
|
if(newNameContainer) { |
|
|
@ -1681,7 +1685,8 @@ export default class ChatBubbles { |
|
|
|
attachmentDiv, |
|
|
|
attachmentDiv, |
|
|
|
middleware: this.getMiddleware(), |
|
|
|
middleware: this.getMiddleware(), |
|
|
|
isOut: our, |
|
|
|
isOut: our, |
|
|
|
lazyLoadQueue: this.lazyLoadQueue |
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
chat: this.chat |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
@ -1748,7 +1753,7 @@ export default class ChatBubbles { |
|
|
|
}); |
|
|
|
}); |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const docDiv = wrapDocument(doc, false, false, message.mid); |
|
|
|
const docDiv = wrapDocument(this.peerId, doc, false, false, message.mid); |
|
|
|
preview.append(docDiv); |
|
|
|
preview.append(docDiv); |
|
|
|
preview.classList.add('preview-with-document'); |
|
|
|
preview.classList.add('preview-with-document'); |
|
|
|
//messageDiv.classList.add((webpage.type || 'document') + '-message');
|
|
|
|
//messageDiv.classList.add((webpage.type || 'document') + '-message');
|
|
|
@ -1865,7 +1870,8 @@ export default class ChatBubbles { |
|
|
|
attachmentDiv, |
|
|
|
attachmentDiv, |
|
|
|
middleware: this.getMiddleware(), |
|
|
|
middleware: this.getMiddleware(), |
|
|
|
isOut: our, |
|
|
|
isOut: our, |
|
|
|
lazyLoadQueue: this.lazyLoadQueue |
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
chat: this.chat |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const withTail = !isAndroid && !isApple && doc.type != 'round' && !message.message; |
|
|
|
const withTail = !isAndroid && !isApple && doc.type != 'round' && !message.message; |
|
|
@ -1890,7 +1896,8 @@ export default class ChatBubbles { |
|
|
|
albumMustBeRenderedFull, |
|
|
|
albumMustBeRenderedFull, |
|
|
|
message, |
|
|
|
message, |
|
|
|
bubble, |
|
|
|
bubble, |
|
|
|
messageDiv |
|
|
|
messageDiv, |
|
|
|
|
|
|
|
chat: this.chat |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if(newNameContainer) { |
|
|
|
if(newNameContainer) { |
|
|
@ -1943,7 +1950,7 @@ export default class ChatBubbles { |
|
|
|
case 'messageMediaPoll': { |
|
|
|
case 'messageMediaPoll': { |
|
|
|
bubble.classList.remove('is-message-empty'); |
|
|
|
bubble.classList.remove('is-message-empty'); |
|
|
|
|
|
|
|
|
|
|
|
const pollElement = wrapPoll(message.media.poll.id, message.mid); |
|
|
|
const pollElement = wrapPoll(this.peerId, message.media.poll.id, message.mid); |
|
|
|
messageDiv.prepend(pollElement); |
|
|
|
messageDiv.prepend(pollElement); |
|
|
|
messageDiv.classList.add('poll-message'); |
|
|
|
messageDiv.classList.add('poll-message'); |
|
|
|
|
|
|
|
|
|
|
@ -2015,7 +2022,7 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(message.reply_to_mid) { |
|
|
|
if(message.reply_to_mid) { |
|
|
|
let originalMessage = this.appMessagesManager.getMessage(message.reply_to_mid); |
|
|
|
let originalMessage = this.chat.getMessage(message.reply_to_mid); |
|
|
|
let originalPeerTitle = this.appPeersManager.getPeerTitle(originalMessage.fromId || originalMessage.fwdFromId, true) || ''; |
|
|
|
let originalPeerTitle = this.appPeersManager.getPeerTitle(originalMessage.fromId || originalMessage.fwdFromId, true) || ''; |
|
|
|
|
|
|
|
|
|
|
|
/////////this.log('message to render reply', originalMessage, originalPeerTitle, bubble, message);
|
|
|
|
/////////this.log('message to render reply', originalMessage, originalPeerTitle, bubble, message);
|
|
|
@ -2023,7 +2030,7 @@ export default class ChatBubbles { |
|
|
|
// need to download separately
|
|
|
|
// need to download separately
|
|
|
|
if(originalMessage._ == 'messageEmpty') { |
|
|
|
if(originalMessage._ == 'messageEmpty') { |
|
|
|
//////////this.log('message to render reply empty, need download', message, message.reply_to_mid);
|
|
|
|
//////////this.log('message to render reply empty, need download', message, message.reply_to_mid);
|
|
|
|
this.appMessagesManager.wrapSingleMessage(message.reply_to_mid); |
|
|
|
this.appMessagesManager.wrapSingleMessage(this.peerId, message.reply_to_mid); |
|
|
|
this.needUpdate.push({replyMid: message.reply_to_mid, mid: message.mid}); |
|
|
|
this.needUpdate.push({replyMid: message.reply_to_mid, mid: message.mid}); |
|
|
|
|
|
|
|
|
|
|
|
originalPeerTitle = 'Loading...'; |
|
|
|
originalPeerTitle = 'Loading...'; |
|
|
@ -2071,7 +2078,7 @@ export default class ChatBubbles { |
|
|
|
bubble.classList.add('hide-name'); |
|
|
|
bubble.classList.add('hide-name'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(this.chat.type == 'pinned') { |
|
|
|
if(this.chat.type === 'pinned') { |
|
|
|
savedFrom = `${this.chat.peerId}_${message.mid}`; |
|
|
|
savedFrom = `${this.chat.peerId}_${message.mid}`; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2163,7 +2170,7 @@ export default class ChatBubbles { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while(history.length) { |
|
|
|
while(history.length) { |
|
|
|
let message = this.appMessagesManager.getMessage(method()); |
|
|
|
let message = this.chat.getMessage(method()); |
|
|
|
this.renderMessage(message, reverse, true); |
|
|
|
this.renderMessage(message, reverse, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2223,9 +2230,9 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
public requestHistory(maxId: number, loadCount: number, backLimit: number) { |
|
|
|
public requestHistory(maxId: number, loadCount: number, backLimit: number) { |
|
|
|
//const middleware = this.getMiddleware();
|
|
|
|
//const middleware = this.getMiddleware();
|
|
|
|
if(this.chat.type == 'chat') { |
|
|
|
if(this.chat.type === 'chat') { |
|
|
|
return this.appMessagesManager.getHistory(this.peerId, maxId, loadCount, backLimit); |
|
|
|
return this.appMessagesManager.getHistory(this.peerId, maxId, loadCount, backLimit); |
|
|
|
} else if(this.chat.type == 'pinned') { |
|
|
|
} else if(this.chat.type === 'pinned') { |
|
|
|
const promise = this.appMessagesManager.getSearch(this.peerId, '', {_: 'inputMessagesFilterPinned'}, maxId, loadCount, 0, backLimit); |
|
|
|
const promise = this.appMessagesManager.getSearch(this.peerId, '', {_: 'inputMessagesFilterPinned'}, maxId, loadCount, 0, backLimit); |
|
|
|
|
|
|
|
|
|
|
|
/* if(maxId) { |
|
|
|
/* if(maxId) { |
|
|
@ -2238,6 +2245,8 @@ export default class ChatBubbles { |
|
|
|
} */ |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
return promise; |
|
|
|
return promise; |
|
|
|
|
|
|
|
} else if(this.chat.type === 'scheduled') { |
|
|
|
|
|
|
|
return this.appMessagesManager.getScheduledMessages(this.peerId).then(mids => ({history: mids})); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2293,7 +2302,7 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
// * filter last album, because we don't know is this the last item
|
|
|
|
// * filter last album, because we don't know is this the last item
|
|
|
|
for(let i = additionMsgIds.length - 1; i >= 0; --i) { |
|
|
|
for(let i = additionMsgIds.length - 1; i >= 0; --i) { |
|
|
|
const message = this.appMessagesManager.getMessage(additionMsgIds[i]); |
|
|
|
const message = this.chat.getMessage(additionMsgIds[i]); |
|
|
|
if(message.grouped_id) additionMsgIds.splice(i, 1); |
|
|
|
if(message.grouped_id) additionMsgIds.splice(i, 1); |
|
|
|
else break; |
|
|
|
else break; |
|
|
|
} |
|
|
|
} |
|
|
@ -2438,7 +2447,7 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
// preload more
|
|
|
|
// preload more
|
|
|
|
//if(!isFirstMessageRender) {
|
|
|
|
//if(!isFirstMessageRender) {
|
|
|
|
if(this.chat.type == 'chat') { |
|
|
|
if(this.chat.type === 'chat') { |
|
|
|
const storage = this.appMessagesManager.historiesStorage[peerId]; |
|
|
|
const storage = this.appMessagesManager.historiesStorage[peerId]; |
|
|
|
const isMaxIdInHistory = storage.history.indexOf(maxId) !== -1; |
|
|
|
const isMaxIdInHistory = storage.history.indexOf(maxId) !== -1; |
|
|
|
if(isMaxIdInHistory) { // * otherwise it is a search or jump
|
|
|
|
if(isMaxIdInHistory) { // * otherwise it is a search or jump
|
|
|
@ -2490,7 +2499,9 @@ export default class ChatBubbles { |
|
|
|
|
|
|
|
|
|
|
|
if(dateMessage.container.childElementCount == 2) { // only date div + sentinel div
|
|
|
|
if(dateMessage.container.childElementCount == 2) { // only date div + sentinel div
|
|
|
|
dateMessage.container.remove(); |
|
|
|
dateMessage.container.remove(); |
|
|
|
this.stickyIntersector.unobserve(dateMessage.container, dateMessage.div); |
|
|
|
if(this.stickyIntersector) { |
|
|
|
|
|
|
|
this.stickyIntersector.unobserve(dateMessage.container, dateMessage.div); |
|
|
|
|
|
|
|
} |
|
|
|
delete this.dateMessages[i]; |
|
|
|
delete this.dateMessages[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|