Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
introduction of refreshWithNote
zadam9f1e777e6df7
diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.jsindex 64c7a15a99..9ba8c36017 100644--- a/src/public/javascripts/desktop.js+++ b/src/public/javascripts/desktop.js@@ -60,7 +60,7 @@ window.glob.noteChanged = noteDetailService.noteChanged;window.glob.refreshTree = treeService.reload;// required for ESLint plugin-window.glob.getActiveTabNote = appContext.getActiveTabNote;+window.glob.getActiveTabNote = () => appContext.getActiveTabNote();window.glob.requireLibrary = libraryLoader.requireLibrary;window.glob.ESLINT = libraryLoader.ESLINT;diff --git a/src/public/javascripts/widgets/attributes.js b/src/public/javascripts/widgets/attributes.jsindex 5e82825354..9505b97573 100644--- a/src/public/javascripts/widgets/attributes.js+++ b/src/public/javascripts/widgets/attributes.js@@ -23,7 +23,7 @@ class AttributesWidget extends StandardWidget {return [$showFullButton];}- async refresh() {+ async refreshWithNote() {const attributes = await this.tabContext.attributes.getAttributes();console.log("attributes", attributes);const ownedAttributes = attributes.filter(attr => attr.noteId === this.tabContext.note.noteId);diff --git a/src/public/javascripts/widgets/basic_widget.js b/src/public/javascripts/widgets/basic_widget.jsindex 4c2df5cb56..5c1fd5f7cb 100644--- a/src/public/javascripts/widgets/basic_widget.js+++ b/src/public/javascripts/widgets/basic_widget.js@@ -17,6 +17,10 @@ class BasicWidget extends Component {doRender() {}toggle(show) {+ if (!this.$widget) {+ console.log(this.componentId);+ }+this.$widget.toggle(show);}diff --git a/src/public/javascripts/widgets/calendar.js b/src/public/javascripts/widgets/calendar.jsindex 4f6ecc9a6f..3bd20ed4f9 100644--- a/src/public/javascripts/widgets/calendar.js+++ b/src/public/javascripts/widgets/calendar.js@@ -38,7 +38,7 @@ class CalendarWidget extends StandardWidget {this.$body.html(TPL);}- async refresh() {+ async refreshWithNote() {this.init(this.$body, await this.tabContext.note.getLabelValue("dateNote"));}diff --git a/src/public/javascripts/widgets/edited_notes.js b/src/public/javascripts/widgets/edited_notes.jsindex 9995d54071..09ec0f5e43 100644--- a/src/public/javascripts/widgets/edited_notes.js+++ b/src/public/javascripts/widgets/edited_notes.js@@ -19,7 +19,7 @@ class EditedNotesWidget extends StandardWidget {&& await this.tabContext.note.hasLabel("dateNote");}- async doRenderBody() {+ async refreshWithNote() {const note = this.tabContext.note;// remember which title was when we found the similar notesthis.title = note.title;diff --git a/src/public/javascripts/widgets/link_map.js b/src/public/javascripts/widgets/link_map.jsindex 9ef32b9295..fd5ebc3fd5 100644--- a/src/public/javascripts/widgets/link_map.js+++ b/src/public/javascripts/widgets/link_map.js@@ -28,7 +28,7 @@ class LinkMapWidget extends StandardWidget {return [$showFullButton];}- async refresh() {+ async refreshWithNote() {this.$body.css('opacity', 0);this.$body.html(TPL);diff --git a/src/public/javascripts/widgets/note_info.js b/src/public/javascripts/widgets/note_info.jsindex 1e52741a45..cc1f392ec2 100644--- a/src/public/javascripts/widgets/note_info.js+++ b/src/public/javascripts/widgets/note_info.js@@ -31,7 +31,7 @@ class NoteInfoWidget extends StandardWidget {this.$body.html(TPL);}- refresh() {+ refreshWithNote() {const $noteId = this.$body.find(".note-info-note-id");const $dateCreated = this.$body.find(".note-info-date-created");const $dateModified = this.$body.find(".note-info-date-modified");diff --git a/src/public/javascripts/widgets/note_paths.js b/src/public/javascripts/widgets/note_paths.jsindex 6ca12b3166..893282358f 100644--- a/src/public/javascripts/widgets/note_paths.js+++ b/src/public/javascripts/widgets/note_paths.js@@ -30,7 +30,7 @@ export default class NotePathsWidget extends TabAwareWidget {return this.$widget;}- async refresh() {+ async refreshWithNote() {const {note, notePath} = this.tabContext;if (note.noteId === 'root') {diff --git a/src/public/javascripts/widgets/note_revisions.js b/src/public/javascripts/widgets/note_revisions.jsindex fdcdd7aa25..fdbff4f177 100644--- a/src/public/javascripts/widgets/note_revisions.js+++ b/src/public/javascripts/widgets/note_revisions.js@@ -26,7 +26,7 @@ class NoteRevisionsWidget extends StandardWidget {return [$showFullButton];}- async refresh() {+ async refreshWithNote() {const note = this.tabContext.note;const revisionItems = await server.get(`notes/${note.noteId}/revisions`);diff --git a/src/public/javascripts/widgets/note_title.js b/src/public/javascripts/widgets/note_title.jsindex 3ba0f53b4a..840f0cd704 100644--- a/src/public/javascripts/widgets/note_title.js+++ b/src/public/javascripts/widgets/note_title.js@@ -130,17 +130,9 @@ export default class NoteTitleWidget extends TabAwareWidget {return this.$widget;}- async refresh() {+ async refreshWithNote() {const note = this.tabContext.note;- if (!note) {- this.toggle(false);- return;- }- else {- this.toggle(true);- }-this.$noteTitle.val(note.title);if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {diff --git a/src/public/javascripts/widgets/note_type.js b/src/public/javascripts/widgets/note_type.jsindex 59d01c585f..bcd06ad406 100644--- a/src/public/javascripts/widgets/note_type.js+++ b/src/public/javascripts/widgets/note_type.js@@ -17,15 +17,14 @@ const NOTE_TYPES = [];const TPL = `-<style>-.note-type-dropdown {- max-height: 500px;- overflow-y: auto;- overflow-x: hidden;-}-</style>-<div class="dropdown note-type">+ <style>+ .note-type-dropdown {+ max-height: 500px;+ overflow-y: auto;+ overflow-x: hidden;+ }+ </style><button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">Type: <span class="note-type-desc"></span><span class="caret"></span>@@ -36,20 +35,20 @@ const TPL = `export default class NoteTypeWidget extends TabAwareWidget {doRender() {- const $widget = $(TPL);+ this.$widget = $(TPL);- $widget.on('show.bs.dropdown', () => this.renderDropdown());+ this.$widget.on('show.bs.dropdown', () => this.renderDropdown());- this.$noteTypeDropdown = $widget.find(".note-type-dropdown");- this.$noteTypeButton = $widget.find(".note-type-button");- this.$noteTypeDesc = $widget.find(".note-type-desc");- this.$executeScriptButton = $widget.find(".execute-script-button");- this.$renderButton = $widget.find('.render-button');+ this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown");+ this.$noteTypeButton = this.$widget.find(".note-type-button");+ this.$noteTypeDesc = this.$widget.find(".note-type-desc");+ this.$executeScriptButton = this.$widget.find(".execute-script-button");+ this.$renderButton = this.$widget.find('.render-button');- return $widget;+ return this.$widget;}- async refresh() {+ async refreshWithNote() {this.$noteTypeButton.prop("disabled",() => ["file", "image", "search"].includes(this.tabContext.note.type));diff --git a/src/public/javascripts/widgets/promoted_attributes.js b/src/public/javascripts/widgets/promoted_attributes.jsindex 0a054472a8..f99d536c31 100644--- a/src/public/javascripts/widgets/promoted_attributes.js+++ b/src/public/javascripts/widgets/promoted_attributes.js@@ -35,14 +35,9 @@ export default class PromotedAttributesWidget extends TabAwareWidget {return this.$widget;}- async refresh() {+ async refreshWithNote() {this.$container.empty();- if (!this.tabContext.note) {- this.toggle(false);- return;- }-const attributes = await this.tabContext.attributes.getAttributes();const promoted = attributes.filter(attr =>diff --git a/src/public/javascripts/widgets/similar_notes.js b/src/public/javascripts/widgets/similar_notes.jsindex 2ede782636..73b191049c 100644--- a/src/public/javascripts/widgets/similar_notes.js+++ b/src/public/javascripts/widgets/similar_notes.js@@ -14,7 +14,7 @@ class SimilarNotesWidget extends StandardWidget {getMaxHeight() { return "200px"; }- async refresh() {+ async refreshWithNote() {// remember which title was when we found the similar notesthis.title = this.tabContext.note.title;diff --git a/src/public/javascripts/widgets/tab_aware_widget.js b/src/public/javascripts/widgets/tab_aware_widget.jsindex c34b243a01..2d2eaab5de 100644--- a/src/public/javascripts/widgets/tab_aware_widget.js+++ b/src/public/javascripts/widgets/tab_aware_widget.js@@ -18,12 +18,21 @@ export default class TabAwareWidget extends BasicWidget {this.refresh();}- // to overrideactiveTabChanged() {this.refresh();}- refresh() {}+ refresh() {+ if (this.tabContext && this.tabContext.note) {+ this.toggle(true);+ this.refreshWithNote();+ }+ else {+ this.toggle(false);+ }+ }++ refreshWithNote() {}activeTabChangedListener() {this.tabContext = this.appContext.getActiveTabContext();diff --git a/src/public/javascripts/widgets/tab_caching_widget.js b/src/public/javascripts/widgets/tab_caching_widget.jsindex 77be5e5d46..a0e96c009e 100644--- a/src/public/javascripts/widgets/tab_caching_widget.js+++ b/src/public/javascripts/widgets/tab_caching_widget.js@@ -35,4 +35,10 @@ export default class TabCachingWidget extends TabAwareWidget {return false; // stop propagation to children}++ toggle(show) {+ for (const tabId in this.widgets) {+ this.widgets[tabId].toggle(show && this.tabContext && tabId === this.tabContext.tabId);+ }+ }}\ No newline at end of filediff --git a/src/public/javascripts/widgets/what_links_here.js b/src/public/javascripts/widgets/what_links_here.jsindex 14caa699c5..0920ddaf1b 100644--- a/src/public/javascripts/widgets/what_links_here.js+++ b/src/public/javascripts/widgets/what_links_here.js@@ -22,7 +22,7 @@ class WhatLinksHereWidget extends StandardWidget {return [$showFullButton];}- async refresh() {+ async refreshWithNote() {const targetRelations = await this.tabContext.note.getTargetRelations();if (targetRelations.length === 0) {