Browse Source

Fix archived tab leak

master
Eduard Kuzmenko 3 years ago
parent
commit
257b540437
  1. 19
      src/components/chat/bubbles.ts
  2. 4
      src/components/sidebarLeft/tabs/archivedTab.ts
  3. 5
      src/lib/appManagers/appDialogsManager.ts

19
src/components/chat/bubbles.ts

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

4
src/components/sidebarLeft/tabs/archivedTab.ts

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

5
src/lib/appManagers/appDialogsManager.ts

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

Loading…
Cancel
Save