Fix archived tab leak

This commit is contained in:
Eduard Kuzmenko 2021-04-16 18:14:50 +04:00
parent 9458e82a96
commit 257b540437
3 changed files with 12 additions and 16 deletions

View File

@ -59,6 +59,7 @@ import findUpClassName from "../../helpers/dom/findUpClassName";
import findUpTag from "../../helpers/dom/findUpTag"; import findUpTag from "../../helpers/dom/findUpTag";
import { toast } from "../toast"; import { toast } from "../toast";
import { getElementByPoint } from "../../helpers/dom/getElementByPoint"; import { getElementByPoint } from "../../helpers/dom/getElementByPoint";
import { getMiddleware } from "../../helpers/middleware";
const USE_MEDIA_TAILS = false; const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS: Message.messageService['action']['_'][] = [/* 'messageActionHistoryClear' */]; const IGNORE_ACTIONS: Message.messageService['action']['_'][] = [/* 'messageActionHistoryClear' */];
@ -115,7 +116,7 @@ export default class ChatBubbles {
public lazyLoadQueue: LazyLoadQueue; public lazyLoadQueue: LazyLoadQueue;
private cleanupObj = {cleaned: false}; private middleware = getMiddleware();
private log: ReturnType<typeof logger>; private log: ReturnType<typeof logger>;
@ -1374,7 +1375,7 @@ export default class ChatBubbles {
// clear messages // clear messages
if(bubblesToo) { if(bubblesToo) {
this.scrollable.container.innerHTML = ''; this.scrollable.container.textContent = '';
} }
this.firstUnreadBubble = null; this.firstUnreadBubble = null;
@ -1396,8 +1397,7 @@ export default class ChatBubbles {
this.loadedTopTimes = this.loadedBottomTimes = 0; this.loadedTopTimes = this.loadedBottomTimes = 0;
this.cleanupObj.cleaned = true; this.middleware.clean();
this.cleanupObj = {cleaned: false};
////console.timeEnd('appImManager cleanup'); ////console.timeEnd('appImManager cleanup');
} }
@ -1497,10 +1497,9 @@ export default class ChatBubbles {
this.isFirstLoad = true; this.isFirstLoad = true;
} }
const oldChatInner = this.chatInner;
this.cleanup(); this.cleanup();
this.chatInner = oldChatInner.cloneNode() as HTMLDivElement; this.chatInner = document.createElement('div');
this.chatInner.classList.remove('disable-hover', 'is-scrolling'); this.chatInner.classList.add('bubbles-inner');
this.lazyLoadQueue.lock(); this.lazyLoadQueue.lock();
@ -1758,12 +1757,8 @@ export default class ChatBubbles {
this.bubbleGroups.addBubble(bubble, message, reverse); this.bubbleGroups.addBubble(bubble, message, reverse);
} }
// * will change .cleaned in cleanup() and new instance will be created
public getMiddleware() { public getMiddleware() {
const cleanupObj = this.cleanupObj; return this.middleware.get();
return () => {
return !cleanupObj.cleaned;
};
} }
// reverse means top // reverse means top

View File

@ -25,9 +25,7 @@ export default class AppArchivedTab extends SliderSuperTab {
this.scrollable.onScrolledBottom = appDialogsManager.onChatsScroll; this.scrollable.onScrolledBottom = appDialogsManager.onChatsScroll;
///this.scroll.attachSentinels(); ///this.scroll.attachSentinels();
appDialogsManager.setListClickListener(chatList, null, true); this.listenerSetter.add(window, 'resize', () => {
window.addEventListener('resize', () => {
setTimeout(appDialogsManager.scroll.checkForTriggers, 0); setTimeout(appDialogsManager.scroll.checkForTriggers, 0);
}); });
} }

View File

@ -227,10 +227,13 @@ export class AppDialogsManager {
private lastActiveElements: Set<HTMLElement> = new Set(); private lastActiveElements: Set<HTMLElement> = new Set();
constructor() { constructor() {
const archivedChatList = this.createChatList();
this.chatLists = { this.chatLists = {
1: this.createChatList() 1: archivedChatList
}; };
this.setListClickListener(archivedChatList, null, true);
this.chatsPreloader = putPreloader(null, true); this.chatsPreloader = putPreloader(null, true);
this.allUnreadCount = this.folders.menu.querySelector('.badge'); this.allUnreadCount = this.folders.menu.querySelector('.badge');