Skip to content

Build your personal knowledge base with Trilium Notes

fixed state persisting and loading

zadamd1d8e54d20e4
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js
index 1ca30469c0..e35f68be7d 100644
--- a/src/public/javascripts/services/note_detail.js
+++ b/src/public/javascripts/services/note_detail.js
@@ -503,12 +503,12 @@ function clearOpenTabsTask() {
}
function openTabsChanged() {
- // we don't want to send too many requests with tab changes so we always schedule task to do this in 3 seconds,
+ // we don't want to send too many requests with tab changes so we always schedule task to do this in 1 seconds,
// but if there's any change in between, we cancel the old one and schedule new one
// so effectively we kind of wait until user stopped e.g. quickly switching tabs
clearOpenTabsTask();
- tabsChangedTaskId = setTimeout(saveOpenTabs, 3000);
+ tabsChangedTaskId = setTimeout(saveOpenTabs, 1000);
}
async function saveOpenTabs() {
diff --git a/src/public/javascripts/services/sidebar.js b/src/public/javascripts/services/sidebar.js
index c78f2a22d6..ed0f416e99 100644
--- a/src/public/javascripts/services/sidebar.js
+++ b/src/public/javascripts/services/sidebar.js
@@ -6,8 +6,9 @@ import AttributesWidget from "../widgets/attributes.js";
class Sidebar {
/**
* @param {TabContext} ctx
+ * @param {object} state
*/
- constructor(ctx, state) {
+ constructor(ctx, state = {}) {
this.ctx = ctx;
this.state = state;
this.widgets = [];
@@ -15,8 +16,6 @@ class Sidebar {
this.$sidebar = ctx.$tabContent.find(".note-detail-sidebar");
this.$widgetContainer = this.$sidebar.find(".note-detail-widget-container");
this.$showSideBarButton = this.ctx.$tabContent.find(".show-sidebar-button");
- this.$showSideBarButton.hide();
-
this.$hideSidebarButton = this.$sidebar.find(".hide-sidebar-button");
this.$hideSidebarButton.click(() => {
@@ -30,10 +29,13 @@ class Sidebar {
this.$showSideBarButton.hide();
this.ctx.stateChanged();
});
+
+ this.$showSideBarButton.toggle(!state.visible);
+ this.$sidebar.toggle(state.visible);
}
isVisible() {
- return this.$sidebar.is(":visible");
+ return this.$sidebar.css("display") !== "none";
}
getSidebarState() {
diff --git a/src/public/javascripts/widgets/standard_widget.js b/src/public/javascripts/widgets/standard_widget.js
index 3f1ba185f7..6bd77e492d 100644
--- a/src/public/javascripts/widgets/standard_widget.js
+++ b/src/public/javascripts/widgets/standard_widget.js
@@ -58,7 +58,7 @@ class StandardWidget {
async doRenderBody() {}
isVisible() {
- return this.$bodyWrapper.is(":visible");
+ return this.$bodyWrapper.hasClass("show");
}
getWidgetState() {