From 539d3ad57b25254b0ed02e5e83eb12125ceeca98 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Mon, 20 Dec 2021 12:36:34 +0400 Subject: [PATCH] Handle resize to change 'All Chats' to 'All' --- src/lib/appManagers/appDialogsManager.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 3defbc81..2f05514e 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -58,6 +58,7 @@ import { NULL_PEER_ID } from "../mtproto/mtproto_config"; import groupCallActiveIcon from "../../components/groupCallActiveIcon"; import { Chat } from "../../layer"; import IS_GROUP_CALL_SUPPORTED from "../../environment/groupCallSupport"; +import mediaSizes from "../../helpers/mediaSizes"; export type DialogDom = { avatarEl: AvatarElement, @@ -329,6 +330,10 @@ export class AppDialogsManager { }); }) */; + mediaSizes.addEventListener('resize', () => { + this.changeFiltersAllChatsKey(); + }); + new ConnectionStatusComponent(this.chatsContainer); this.chatsContainer.append(bottomPart); @@ -779,6 +784,15 @@ export class AppDialogsManager { this.onFiltersLengthChange(); } + private changeFiltersAllChatsKey() { + const scrollable = this.folders.menuScrollContainer.firstElementChild; + const key: LangPackKey = scrollable.scrollWidth > scrollable.clientWidth ? 'FilterAllChatsShort' : 'FilterAllChats'; + if(this.allChatsIntlElement.key !== key) { + this.allChatsIntlElement.key = key; + this.allChatsIntlElement.update(); + } + } + private onFiltersLengthChange() { if(!this.showFiltersPromise) { this.showFiltersPromise = new Promise((resolve) => { @@ -796,12 +810,7 @@ export class AppDialogsManager { this.chatsContainer.classList.toggle('has-filters', show); } - const scrollable = this.folders.menuScrollContainer.firstElementChild; - const key: LangPackKey = scrollable.scrollWidth > scrollable.clientWidth ? 'FilterAllChatsShort' : 'FilterAllChats'; - if(this.allChatsIntlElement.key !== key) { - this.allChatsIntlElement.key = key; - this.allChatsIntlElement.update(); - } + this.changeFiltersAllChatsKey(); this.showFiltersPromise = undefined; resolve();