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
fixes
zadamba500a3a8063
diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.jsindex a9840cd9c4..bcc849dfbf 100644--- a/src/public/javascripts/services/app_context.js+++ b/src/public/javascripts/services/app_context.js@@ -253,7 +253,6 @@ class AppContext {const tabContext = new TabContext(this, this.tabRow);this.tabContexts.push(tabContext);this.components.push(tabContext);-return tabContext;}@@ -321,9 +320,11 @@ class AppContext {}activateTab(tabId) {+ const oldActiveTabId = this.activeTabId;+this.activeTabId = tabId;- this.trigger('activeTabChanged', { tabId: this.activeTabId });+ this.trigger('activeTabChanged', { oldActiveTabId });}newTabListener() {diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex 1de5f5c28b..8230fc01ab 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -69,6 +69,7 @@ class TabContext extends Component {}}, 5000);+ // should be done somewhere else ...bundleService.executeRelationBundles(this.note, 'runOnNoteView', this);if (this.note.isProtected && protectedSessionHolder.isProtectedSessionAvailable()) {diff --git a/src/public/javascripts/widgets/basic_widget.js b/src/public/javascripts/widgets/basic_widget.jsindex 0bf4fdc4ac..359fd034a5 100644--- a/src/public/javascripts/widgets/basic_widget.js+++ b/src/public/javascripts/widgets/basic_widget.js@@ -24,10 +24,6 @@ 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/component.js b/src/public/javascripts/widgets/component.jsindex 6b78547c18..ce813c0a44 100644--- a/src/public/javascripts/widgets/component.js+++ b/src/public/javascripts/widgets/component.js@@ -22,12 +22,10 @@ export default class Component {}if (propagateToChildren) {- for (const child of this.children) {- let promise = child.eventReceived(name, data, sync);+ const promise = this.triggerChildren(name, data, sync);- if (sync) {- await promise;- }+ if (sync) {+ await promise;}}}@@ -35,4 +33,14 @@ export default class Component {trigger(name, data, sync = false) {this.appContext.trigger(name, data, sync);}++ async triggerChildren(name, data, sync = false) {+ for (const child of this.children) {+ let promise = child.eventReceived(name, data, sync);++ if (sync) {+ await promise;+ }+ }+ }}\ No newline at end of filediff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.jsindex 38928bd61d..cbbeac435e 100644--- a/src/public/javascripts/widgets/note_detail.js+++ b/src/public/javascripts/widgets/note_detail.js@@ -1,7 +1,6 @@import TabAwareWidget from "./tab_aware_widget.js";import utils from "../services/utils.js";import protectedSessionHolder from "../services/protected_session_holder.js";-import appContext from "../services/app_context.js";import SpacedUpdate from "../services/spaced_update.js";import server from "../services/server.js";import libraryLoader from "../services/library_loader.js";@@ -81,13 +80,7 @@ export default class NoteDetailWidget extends TabAwareWidget {}async refresh() {- this.type = this.getWidgetType(/*disableAutoBook*/);-- if (!(this.type in this.typeWidgetPromises)) {- this.typeWidgetPromises[this.type] = this.initWidgetType(this.type);- }-- await this.typeWidgetPromises[this.type];+ await this.initType();for (const typeWidget of Object.values(this.typeWidgets)) {if (typeWidget.constructor.getType() !== this.type) {@@ -101,6 +94,20 @@ export default class NoteDetailWidget extends TabAwareWidget {this.setupClasses();}+ async initType() {+ do {+ this.type = this.getWidgetType();++ console.log(`Note detail type = ${this.type} for ${this.tabContext.tabId}`);++ if (!(this.type in this.typeWidgetPromises)) {+ this.typeWidgetPromises[this.type] = this.initWidgetType(this.type);+ }++ await this.typeWidgetPromises[this.type];+ } while (this.type !== this.getWidgetType());+ }+setupClasses() {for (const clazz of Array.from(this.$widget[0].classList)) { // create copy to safely iterate over while removing classesif (clazz !== 'note-detail') {@@ -130,7 +137,7 @@ export default class NoteDetailWidget extends TabAwareWidget {async initWidgetType(type) {const clazz = await import(typeWidgetClasses[type]);- const typeWidget = this.typeWidgets[this.type] = new clazz.default(this.appContext);+ const typeWidget = this.typeWidgets[type] = new clazz.default(this.appContext);this.children.push(typeWidget);this.$widget.append(typeWidget.render());@@ -209,4 +216,10 @@ export default class NoteDetailWidget extends TabAwareWidget {protectedSessionStartedListener() {this.refresh();}++ async eventReceived(name, data, sync = false) {+ console.log("Received ", name, data);++ super.eventReceived(name, data, sync);+ }}\ No newline at end of filediff --git a/src/public/javascripts/widgets/tab_caching_widget.js b/src/public/javascripts/widgets/tab_caching_widget.jsindex 75fd65f02e..19cfde1820 100644--- a/src/public/javascripts/widgets/tab_caching_widget.js+++ b/src/public/javascripts/widgets/tab_caching_widget.js@@ -21,6 +21,8 @@ export default class TabCachingWidget extends TabAwareWidget {}if (!this.tabContext) {+ console.log(`Received activeTabChanged to widget ${this.componentId} which does not have tabContext.`);+return;}diff --git a/src/public/javascripts/widgets/type_widgets/empty.js b/src/public/javascripts/widgets/type_widgets/empty.jsindex f433f02ed3..400da076df 100644--- a/src/public/javascripts/widgets/type_widgets/empty.js+++ b/src/public/javascripts/widgets/type_widgets/empty.js@@ -36,13 +36,14 @@ export default class EmptyTypeWidget extends TypeWidget {return this.$widget;}- refresh() {- if (this.tabContext.note) {- this.toggle(false);- return;- }+ toggle(show) {+ console.log("EMPTY TOGGLE", show);++ super.toggle(show);+ }- this.toggle(true);+ refresh() {+ this.toggle(!this.tabContext.note);}show() {}