Fix following by album item

This commit is contained in:
morethanwords 2020-10-13 00:32:12 +03:00
parent 1b6fc2622e
commit 5b4052e5c3

View File

@ -316,17 +316,9 @@ export class AppImManager {
let {peerID, mid, id, justMedia} = e.detail; let {peerID, mid, id, justMedia} = e.detail;
if(peerID != this.peerID) return; if(peerID != this.peerID) return;
let message = appMessagesManager.getMessage(mid); const mounted = this.getMountedBubble(mid);
if(!mounted) return;
let bubble = this.bubbles[mid]; this.renderMessage(mounted.message, true, false, mounted.bubble, false);
if(!bubble && message.grouped_id) {
let a = this.getAlbumBubble(message.grouped_id);
bubble = a.bubble;
message = a.message;
}
if(!bubble) return;
this.renderMessage(message, true, false, bubble, false);
}); });
$rootScope.$on('peer_pinned_message', (e) => { $rootScope.$on('peer_pinned_message', (e) => {
@ -1002,7 +994,20 @@ export class AppImManager {
////console.timeEnd('appImManager cleanup'); ////console.timeEnd('appImManager cleanup');
} }
private findMountedBubbleByMsgID(mid: number) { public getMountedBubble(mid: number) {
let message = appMessagesManager.getMessage(mid);
let bubble = this.bubbles[mid];
if(!bubble && message.grouped_id) {
const a = this.getAlbumBubble(message.grouped_id);
if(a) return a;
}
if(!bubble) return;
return {bubble, message};
}
private findNextMountedBubbleByMsgID(mid: number) {
return this.bubbles[getObjectKeysAndSort(this.bubbles).find(id => { return this.bubbles[getObjectKeysAndSort(this.bubbles).find(id => {
if(id < mid) return false; if(id < mid) return false;
return !!this.bubbles[id]?.parentElement; return !!this.bubbles[id]?.parentElement;
@ -1064,11 +1069,11 @@ export class AppImManager {
} }
if(samePeer) { if(samePeer) {
if(this.bubbles[lastMsgID]) { const mounted = this.getMountedBubble(lastMsgID);
if(mounted) {
if(isTarget) { if(isTarget) {
const bubble = this.findMountedBubbleByMsgID(lastMsgID); this.scrollable.scrollIntoView(mounted.bubble);
this.scrollable.scrollIntoView(bubble); this.highlightBubble(mounted.bubble);
this.highlightBubble(bubble);
} else if(dialog && lastMsgID == topMessage) { } else if(dialog && lastMsgID == topMessage) {
//this.log('will scroll down', this.scroll.scrollTop, this.scroll.scrollHeight); //this.log('will scroll down', this.scroll.scrollTop, this.scroll.scrollHeight);
this.scroll.scrollTop = this.scroll.scrollHeight; this.scroll.scrollTop = this.scroll.scrollHeight;
@ -1176,7 +1181,7 @@ export class AppImManager {
let bubble: HTMLElement = forwardingUnread ? (this.firstUnreadBubble || this.bubbles[lastMsgID]) : this.bubbles[lastMsgID]; let bubble: HTMLElement = forwardingUnread ? (this.firstUnreadBubble || this.bubbles[lastMsgID]) : this.bubbles[lastMsgID];
if(!bubble?.parentElement) { if(!bubble?.parentElement) {
bubble = this.findMountedBubbleByMsgID(lastMsgID); bubble = this.findNextMountedBubbleByMsgID(lastMsgID);
} }
this.scrollable.scrollIntoView(bubble, samePeer/* , fromUp */); this.scrollable.scrollIntoView(bubble, samePeer/* , fromUp */);