From 8eca6fd1ddbf2ca41322f81b874c9d306109ead4 Mon Sep 17 00:00:00 2001 From: H7GhosT Date: Sat, 21 Dec 2024 21:23:52 +0200 Subject: [PATCH] Adjust background when changing sidebar width --- src/components/sidebarLeft/index.ts | 2 ++ src/lib/appManagers/appImManager.ts | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/sidebarLeft/index.ts b/src/components/sidebarLeft/index.ts index f787bdffb..402d83b45 100644 --- a/src/components/sidebarLeft/index.ts +++ b/src/components/sidebarLeft/index.ts @@ -503,6 +503,8 @@ export class AppSidebarLeft extends SidebarSlider { const isCollapsed = !this.hasTabsInNavigation() && !this.isSearchActive && width < MIN_SIDEBAR_WIDTH * 0.65; this.sidebarEl.classList.toggle('is-collapsed', isCollapsed); + appImManager.adjustChatPatternBackground(); + throttledSetToStorage(isCollapsed ? 0 : clampedWidth); }, onReset: () => { diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index d0879f87d..0256cc969 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -312,15 +312,13 @@ export class AppImManager extends EventListenerBase<{ mediaSizes.addEventListener('resize', () => { // const perf = performance.now(); - const rect = this.chatsContainer.getBoundingClientRect(); - ChatBackgroundPatternRenderer.resizeInstances(rect.width, rect.height).then(() => { - // this.log.warn('resize bg time:', performance.now() - perf); - // for(const chat of this.chats) { - // if(chat.renderDarkPattern) { - // chat.renderDarkPattern(); - // } - // } - }); + this.adjustChatPatternBackground(); + // this.log.warn('resize bg time:', performance.now() - perf); + // for(const chat of this.chats) { + // if(chat.renderDarkPattern) { + // chat.renderDarkPattern(); + // } + // } }); const onPeerChanging = (chat: Chat) => { @@ -691,6 +689,11 @@ export class AppImManager extends EventListenerBase<{ // PopupElement.createPopup(PopupBoostsViaGifts, -5000866300); } + public adjustChatPatternBackground() { + const rect = this.chatsContainer.getBoundingClientRect(); + ChatBackgroundPatternRenderer.resizeInstances(rect.width, rect.height); + } + private checkForShare() { const share = apiManagerProxy.share; if(share) {