diff --git a/src/public/javascripts/services/sidebar.js b/src/public/javascripts/services/sidebar.js index be8688ff8..bf1eee019 100644 --- a/src/public/javascripts/services/sidebar.js +++ b/src/public/javascripts/services/sidebar.js @@ -14,7 +14,6 @@ class Sidebar { widgets: [] }, state); this.widgets = []; - this.rendered = false; 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"); @@ -54,7 +53,9 @@ class Sidebar { } for (const widget of this.widgets) { - widget.cleanup(); + if (widget.cleanup) { + widget.cleanup(); + } } this.widgets = []; @@ -100,7 +101,7 @@ class Sidebar { this.$widgetContainer.append($el); } catch (e) { - ws.logError(`Error while loading widget ${widget.widgetName}: ${e.message}`); + ws.logError(`Error while rendering widget ${widget.widgetName}: ${e.message}`); } } } diff --git a/src/public/javascripts/widgets/similar_notes.js b/src/public/javascripts/widgets/similar_notes.js index d1a3bf2e0..2492f9f4a 100644 --- a/src/public/javascripts/widgets/similar_notes.js +++ b/src/public/javascripts/widgets/similar_notes.js @@ -11,8 +11,6 @@ class SimilarNotesWidget extends StandardWidget { async doRenderBody() { const similarNoteIds = await server.get('similar_notes/' + this.ctx.note.noteId); - console.log(similarNoteIds); - if (similarNoteIds.length === 0) { this.$body.text("No similar notes found ..."); return; diff --git a/src/public/javascripts/widgets/standard_widget.js b/src/public/javascripts/widgets/standard_widget.js index 0e0ea9019..dcd7e9d6b 100644 --- a/src/public/javascripts/widgets/standard_widget.js +++ b/src/public/javascripts/widgets/standard_widget.js @@ -89,7 +89,16 @@ class StandardWidget { async doRenderBody() {} async isEnabled() { - return this.widgetOptions.enabled; + const label = await this.ctx.note.getLabelValue(this.widgetName); + + if (label === 'enabled') { + return true; + } else if (label === 'disabled') { + return false; + } + else { + return this.widgetOptions.enabled; + } } isExpanded() {