state management fixes

This commit is contained in:
zadam
2019-08-28 20:29:10 +02:00
parent ff1d312a43
commit 650d9e0b27
8 changed files with 20 additions and 16 deletions

View File

@@ -10,7 +10,9 @@ class Sidebar {
constructor(ctx, state = {}) {
/** @property {TabContext} */
this.ctx = ctx;
this.state = state;
this.state = Object.assign({
widgets: []
}, state);
this.widgets = [];
this.rendered = false;
this.$sidebar = ctx.$tabContent.find(".note-detail-sidebar");
@@ -73,10 +75,8 @@ class Sidebar {
}
for (const widgetClass of widgetClasses) {
const state = (this.state.widgets || []).find(s => s.name === widgetClass.name);
try {
const widget = new widgetClass(this.ctx, options, state);
const widget = new widgetClass(this.ctx, options, this.state);
if (await widget.isEnabled()) {
this.widgets.push(widget);