fixed state persisting and loading

This commit is contained in:
zadam 2019-08-16 21:52:36 +02:00
parent f259c60b54
commit d1d8e54d20
3 changed files with 9 additions and 7 deletions

View file

@ -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() {

View file

@ -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() {

View file

@ -58,7 +58,7 @@ class StandardWidget {
async doRenderBody() {}
isVisible() {
return this.$bodyWrapper.is(":visible");
return this.$bodyWrapper.hasClass("show");
}
getWidgetState() {