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

63 lines
2.0 KiB
TypeScript
Raw Normal View History

2021-04-08 15:52:31 +02:00
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
import { SliderSuperTab } from "../../slider";
2021-02-20 18:10:26 +01:00
export default class AppArchivedTab extends SliderSuperTab {
2021-03-26 16:29:10 +01:00
public static filterId = 1;
public loadedAll: boolean;
public loadDialogsPromise: Promise<any>;
public wasFilterId: number;
init() {
2021-02-20 18:10:26 +01:00
this.container.id = 'chats-archived-container';
2021-03-23 17:13:35 +01:00
this.setTitle('ArchivedChats');
2021-02-20 18:10:26 +01:00
//this.scrollable = new Scrollable(this.container, 'CLA', 500);
2021-03-26 16:29:10 +01:00
const chatList = appDialogsManager.chatLists[AppArchivedTab.filterId];
this.scrollable.append(chatList);
2021-02-20 18:10:26 +01:00
this.scrollable.container.addEventListener('scroll', appDialogsManager.onChatsRegularScroll);
2021-03-26 16:29:10 +01:00
this.scrollable.setVirtualContainer(chatList);
2021-02-20 18:10:26 +01:00
this.scrollable.onScrolledBottom = appDialogsManager.onChatsScroll;
///this.scroll.attachSentinels();
2021-03-26 16:29:10 +01:00
appDialogsManager.setListClickListener(chatList, null, true);
window.addEventListener('resize', () => {
setTimeout(appDialogsManager.scroll.checkForTriggers, 0);
});
}
onOpen() {
if(this.init) {
this.init();
this.init = null;
}
this.wasFilterId = appDialogsManager.filterId;
2021-02-20 18:10:26 +01:00
appDialogsManager.scroll = this.scrollable;
2021-03-26 16:29:10 +01:00
appDialogsManager.filterId = AppArchivedTab.filterId;
appDialogsManager.onTabChange();
}
// вообще, так делать нельзя, но нет времени чтобы переделать главный чатлист на слайд...
onOpenAfterTimeout() {
appDialogsManager.chatLists[this.wasFilterId].innerHTML = '';
}
onClose() {
appDialogsManager.scroll = appDialogsManager._scroll;
appDialogsManager.filterId = this.wasFilterId;
appDialogsManager.onTabChange();
}
onCloseAfterTimeout() {
2021-03-26 16:29:10 +01:00
appDialogsManager.chatLists[AppArchivedTab.filterId].innerHTML = '';
2021-02-20 18:10:26 +01:00
return super.onCloseAfterTimeout();
}
}