From 29c4d9ffd01277c280568ed374eb858b7f414f94 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Fri, 28 May 2021 10:03:46 +0100 Subject: [PATCH] Restore toggle LHS logic --- src/components/structures/MatrixChat.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index c01437b313..32916a590b 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -232,6 +232,7 @@ export default class MatrixChat extends React.PureComponent { private accountPasswordTimer?: NodeJS.Timeout; private focusComposer: boolean; private subTitleStatus: string; + private prevWindowWidth: number; private readonly loggedInView: React.RefObject; private readonly dispatcherRef: any; @@ -277,6 +278,7 @@ export default class MatrixChat extends React.PureComponent { } } + this.prevWindowWidth = UIStore.instance.windowWidth || 1000; UIStore.instance.on(UI_EVENTS.Resize, this.handleResize); this.pageChanging = false; @@ -1821,13 +1823,15 @@ export default class MatrixChat extends React.PureComponent { const LHS_THRESHOLD = 1000; const width = UIStore.instance.windowWidth; - if (width <= LHS_THRESHOLD && !this.state.collapseLhs) { - dis.dispatch({ action: 'hide_left_panel' }); - } - if (width > LHS_THRESHOLD && this.state.collapseLhs) { + if (this.prevWindowWidth < LHS_THRESHOLD && width >= LHS_THRESHOLD) { dis.dispatch({ action: 'show_left_panel' }); } + if (this.prevWindowWidth >= LHS_THRESHOLD && width < LHS_THRESHOLD) { + dis.dispatch({ action: 'hide_left_panel' }); + } + + this.prevWindowWidth = width; this.state.resizeNotifier.notifyWindowResized(); };