From 4d1713203a67f26e114053feeb63069ba3dcd072 Mon Sep 17 00:00:00 2001 From: danieldeng2 <danieldeng223@gmail.com> Date: Fri, 4 Sep 2020 00:12:34 +0100 Subject: [PATCH] Change sidebar behaviour --- src/components/App.tsx | 18 +++++++----------- src/components/pages/Timeline/index.tsx | 1 - 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index cbac02617..a10aae6e0 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -22,7 +22,8 @@ type AppState = { class App extends React.Component<{}, AppState> { width = window.innerWidth; - isSideBarSet = false; + isTimelineView = false; + constructor(props: {}) { super(props); this.state = { @@ -53,10 +54,7 @@ class App extends React.Component<{}, AppState> { this.showOrHideSideBars(); } }); - if (!this.isSideBarSet) { - console.log("showOrHideSideBars"); - this.showOrHideSideBars(); - } + this.showOrHideSideBars(); } setDarkTheme(toSet: boolean) { @@ -89,7 +87,7 @@ class App extends React.Component<{}, AppState> { } showOrHideSideBars() { - if (window.innerWidth <= 1024) { + if (window.innerWidth <= 1024 || this.isTimelineView) { this.setState({ toggledLeft: false, toggledRight: false, @@ -149,13 +147,11 @@ class App extends React.Component<{}, AppState> { toggledLeft={this.state.toggledLeft} toggledRight={this.state.toggledRight} initTimelineSideBar={() => { - this.setState({ - toggledLeft: false, - toggledRight: false, - }); - this.isSideBarSet = true; + this.isTimelineView = true; + this.showOrHideSideBars(); }} revertTimelineSideBar={() => { + this.isTimelineView = false; this.showOrHideSideBars(); }} onOverlayClick={(e) => { diff --git a/src/components/pages/Timeline/index.tsx b/src/components/pages/Timeline/index.tsx index 5eb64241b..3347c1f34 100644 --- a/src/components/pages/Timeline/index.tsx +++ b/src/components/pages/Timeline/index.tsx @@ -9,7 +9,6 @@ class Timeline extends React.Component<TimelineProps, {}> { componentDidMount() {; this.props.initSideBar(); - console.log("mounted"); } componentWillUnmount() { -- GitLab