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
reduce unnecessary tab activation events
zadam52a907651ebc
diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.jsindex d532683187..133786bffe 100644--- a/src/public/javascripts/services/app_context.js+++ b/src/public/javascripts/services/app_context.js@@ -314,6 +314,10 @@ class AppContext {}activateTab(tabId) {+ if (tabId === this.activeTabId) {+ return;+ }+const oldActiveTabId = this.activeTabId;this.activeTabId = tabId;diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex eed5f2dc2d..bc1a7b67c6 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -44,7 +44,6 @@ class TabContext extends Component {}if (notePath === this.notePath) {- console.log(`Setting existing notePath ${notePath} so ignoring ...`);return;}diff --git a/src/public/javascripts/widgets/component.js b/src/public/javascripts/widgets/component.jsindex 8da089c984..ce813c0a44 100644--- a/src/public/javascripts/widgets/component.js+++ b/src/public/javascripts/widgets/component.js@@ -11,7 +11,7 @@ export default class Component {async eventReceived(name, data, sync = false) {await this.initialized;- console.log(`Received ${name} to ${this.componentId}`);+// console.log(`Received ${name} to ${this.componentId}`);const fun = this[name + 'Listener'];diff --git a/src/public/javascripts/widgets/type_widgets/book.js b/src/public/javascripts/widgets/type_widgets/book.jsindex aa71788bb7..b9d071cbd2 100644--- a/src/public/javascripts/widgets/type_widgets/book.js+++ b/src/public/javascripts/widgets/type_widgets/book.js@@ -218,6 +218,10 @@ export default class BookTypeWidget extends TypeWidget {async renderIntoElement(note, $container) {const childNotes = await note.getChildNotes();+ if (childNotes.length === 0) {+ this.$help.show();+ }+for (const childNote of childNotes) {const childNotePath = this.tabContext.notePath + '/' + childNote.noteId;@@ -246,10 +250,6 @@ export default class BookTypeWidget extends TypeWidget {$container.append($card);}-- if (childNotes.length === 0) {- this.$help.show();- }}/** @return {boolean} true if this is "auto book" activated (empty text note) and not explicit book note */@@ -276,10 +276,7 @@ export default class BookTypeWidget extends TypeWidget {}}- getContent() {- // for auto-book cases when renaming title there should be content- return "";- }+ getContent() {}focus() {}