From 8d49249ed78647a0f624b86b49cae8ef3cb03fe8 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 6 Feb 2020 20:04:43 +0100 Subject: [PATCH] fix lazy initialization of the sidebar --- package-lock.json | 6 +++--- package.json | 2 +- src/public/javascripts/services/app_context.js | 8 ++++---- .../widgets/{sidebar_toggle.js => side_pane_toggles.js} | 2 +- src/public/javascripts/widgets/tab_aware_widget.js | 4 ++++ 5 files changed, 13 insertions(+), 9 deletions(-) rename src/public/javascripts/widgets/{sidebar_toggle.js => side_pane_toggles.js} (97%) diff --git a/package-lock.json b/package-lock.json index 203d65d5d..b6795e352 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3782,9 +3782,9 @@ } }, "file-type": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-14.1.0.tgz", - "integrity": "sha512-HfxnzrPH+LLClSAsno88/0frRtamu1XfqEP4IP/8RqBmqQnBQkemv3Udde0t53wZmrdOtc70aaR9WUHyQhjCUQ==", + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-14.1.1.tgz", + "integrity": "sha512-fGmNwmRgDi3uMDNbJfRRKaOUGN/uzeWRl2Ti9RJdvLpzFMKbl5cBGP3ngHYKiBSbHPB8wzMckP9x9SixJDFftg==", "requires": { "readable-web-to-node-stream": "^2.0.0", "strtok3": "^6.0.0", diff --git a/package.json b/package.json index 6c6a3faf8..f1a139d2b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "electron-window-state": "5.0.3", "express": "4.17.1", "express-session": "1.17.0", - "file-type": "14.1.0", + "file-type": "14.1.1", "fs-extra": "8.1.0", "helmet": "3.21.2", "html": "1.0.0", diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.js index 365f5fc8f..dbfad1210 100644 --- a/src/public/javascripts/services/app_context.js +++ b/src/public/javascripts/services/app_context.js @@ -34,7 +34,7 @@ import utils from "./utils.js"; import treeService from "./tree.js"; import SidePaneContainer from "../widgets/side_pane_container.js"; import ZoomService from "./zoom.js"; -import SidepaneToggles from "../widgets/sidebar_toggle.js"; +import SidePaneToggles from "../widgets/side_pane_toggles.js"; class AppContext { constructor() { @@ -188,9 +188,9 @@ class AppContext { $centerPane.after(rightPaneContainer.render()); - const sidebarToggleWidget = new SidepaneToggles(this); + const sidePaneTogglesWidget = new SidePaneToggles(this); - $centerPane.after(sidebarToggleWidget.render()); + $centerPane.after(sidePaneTogglesWidget.render()); this.components = [ new Entrypoints(), @@ -199,7 +199,7 @@ class AppContext { leftPaneContainer, ...centerPaneWidgets, rightPaneContainer, - sidebarToggleWidget + sidePaneTogglesWidget ]; if (utils.isElectron()) { diff --git a/src/public/javascripts/widgets/sidebar_toggle.js b/src/public/javascripts/widgets/side_pane_toggles.js similarity index 97% rename from src/public/javascripts/widgets/sidebar_toggle.js rename to src/public/javascripts/widgets/side_pane_toggles.js index 7f64e8c9d..45253f222 100644 --- a/src/public/javascripts/widgets/sidebar_toggle.js +++ b/src/public/javascripts/widgets/side_pane_toggles.js @@ -28,7 +28,7 @@ const TPL = ` `; -export default class SidepaneToggles extends BasicWidget { +export default class SidePaneToggles extends BasicWidget { constructor(appContext) { super(appContext); diff --git a/src/public/javascripts/widgets/tab_aware_widget.js b/src/public/javascripts/widgets/tab_aware_widget.js index e29c79488..0ec19ca0a 100644 --- a/src/public/javascripts/widgets/tab_aware_widget.js +++ b/src/public/javascripts/widgets/tab_aware_widget.js @@ -78,6 +78,10 @@ export default class TabAwareWidget extends BasicWidget { } lazyLoadedListener() { + if (!this.tabContext) { // has not been loaded yet + this.tabContext = this.appContext.getActiveTabContext(); + } + this.refresh(); } } \ No newline at end of file