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
|
|
|
|
*/
|
|
|
|
|
2020-10-07 15:57:33 +02:00
|
|
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
|
2021-02-28 21:14:01 +01:00
|
|
|
import { SliderSuperTab } from "../../slider";
|
2020-10-07 15:57:33 +02:00
|
|
|
|
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;
|
2020-10-07 15:57:33 +02:00
|
|
|
public loadedAll: boolean;
|
|
|
|
public loadDialogsPromise: Promise<any>;
|
2020-12-11 03:06:16 +01:00
|
|
|
public wasFilterId: number;
|
2020-10-07 15:57:33 +02:00
|
|
|
|
|
|
|
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;
|
2020-10-07 15:57:33 +02:00
|
|
|
///this.scroll.attachSentinels();
|
|
|
|
|
2021-03-26 16:29:10 +01:00
|
|
|
appDialogsManager.setListClickListener(chatList, null, true);
|
2020-10-07 15:57:33 +02:00
|
|
|
|
|
|
|
window.addEventListener('resize', () => {
|
2020-11-14 00:04:03 +01:00
|
|
|
setTimeout(appDialogsManager.scroll.checkForTriggers, 0);
|
2020-10-07 15:57:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpen() {
|
|
|
|
if(this.init) {
|
|
|
|
this.init();
|
|
|
|
this.init = null;
|
|
|
|
}
|
|
|
|
|
2020-12-11 03:06:16 +01:00
|
|
|
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;
|
2020-10-07 15:57:33 +02:00
|
|
|
appDialogsManager.onTabChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
// вообще, так делать нельзя, но нет времени чтобы переделать главный чатлист на слайд...
|
|
|
|
onOpenAfterTimeout() {
|
2020-12-11 03:06:16 +01:00
|
|
|
appDialogsManager.chatLists[this.wasFilterId].innerHTML = '';
|
2020-10-07 15:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onClose() {
|
|
|
|
appDialogsManager.scroll = appDialogsManager._scroll;
|
2020-12-11 03:06:16 +01:00
|
|
|
appDialogsManager.filterId = this.wasFilterId;
|
2020-10-07 15:57:33 +02:00
|
|
|
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();
|
2020-10-07 15:57:33 +02:00
|
|
|
}
|
|
|
|
}
|