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
zadam7767edd82fb2
diff --git a/src/public/javascripts/services/app_context.js b/src/public/javascripts/services/app_context.jsindex 94abda6a06..71f092beb7 100644--- a/src/public/javascripts/services/app_context.js+++ b/src/public/javascripts/services/app_context.js@@ -29,8 +29,15 @@ class AppContext {showWidgets() {const rootContainer = this.layout.getRootWidget(this);+ const $renderedWidget = rootContainer.render();- $("body").append(rootContainer.render());+ $("body").append($renderedWidget);++ $renderedWidget.on('click', "[data-trigger-event]", e => {+ const eventName = $(e.target).attr('data-trigger-event');++ this.trigger(eventName);+ });this.components = [this.tabManager,diff --git a/src/public/javascripts/services/branches.js b/src/public/javascripts/services/branches.jsindex 9f9a79c58d..1e54e797ad 100644--- a/src/public/javascripts/services/branches.js+++ b/src/public/javascripts/services/branches.js@@ -1,11 +1,9 @@-import treeService from './tree.js';import utils from './utils.js';import server from './server.js';import toastService from "./toast.js";import treeCache from "./tree_cache.js";import hoistedNoteService from "./hoisted_note.js";import ws from "./ws.js";-import appContext from "./app_context.js";async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {branchIdsToMove = await filterRootNote(branchIdsToMove);@@ -121,8 +119,6 @@ async function deleteNodes(branchIdsToDelete) {}}- const noteIds = Array.from(new Set(nodes.map(node => node.getParent().data.noteId)));-return true;}diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.jsindex ee91692830..e755c5d5c2 100644--- a/src/public/javascripts/services/tab_context.js+++ b/src/public/javascripts/services/tab_context.js@@ -100,15 +100,19 @@ class TabContext extends Component {}}- noteDeletedListener({noteId}) {- if (this.noteId === noteId) {- this.noteId = null;- this.notePath = null;-- this.trigger('tabNoteSwitched', {- tabId: this.tabId,- notePath: this.notePath- });+ async entitiesReloadedListener({loadResults}) {+ if (loadResults.isNoteReloaded(this.noteId)) {+ const note = await treeCache.getNote(this.noteId);++ if (note.isDeleted) {+ this.noteId = null;+ this.notePath = null;++ this.trigger('tabNoteSwitched', {+ tabId: this.tabId,+ notePath: this.notePath+ });+ }}}}diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex 2df5d74bd3..29f3b2e8cb 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -86,7 +86,7 @@ async function getRunPath(notePath) {break;}else {- ws.logError("No parents, can't activate node.");+ console.log("No parents so no run path.");return;}}diff --git a/src/public/javascripts/services/ws.js b/src/public/javascripts/services/ws.jsindex 714c9eaa1b..3ac74abc9e 100644--- a/src/public/javascripts/services/ws.js+++ b/src/public/javascripts/services/ws.js@@ -218,6 +218,9 @@ async function processSyncRows(syncRows) {const parentNote = treeCache.notes[sync.entity.parentNoteId];if (branch) {+ branch.update(sync.entity);+ loadResults.addBranch(sync.entityId, sync.sourceId);+if (sync.entity.isDeleted) {if (childNote) {childNote.parents = childNote.parents.filter(parentNoteId => parentNoteId !== sync.entity.parentNoteId);@@ -230,9 +233,6 @@ async function processSyncRows(syncRows) {}}else {- branch.update(sync.entity);- loadResults.addBranch(sync.entityId, sync.sourceId);-if (childNote) {childNote.addParent(branch.parentNoteId, branch.branchId);}diff --git a/src/public/javascripts/widgets/basic_widget.js b/src/public/javascripts/widgets/basic_widget.jsindex 006fc6a732..d694157f36 100644--- a/src/public/javascripts/widgets/basic_widget.js+++ b/src/public/javascripts/widgets/basic_widget.js@@ -7,12 +7,6 @@ class BasicWidget extends Component {keyboardActionsService.updateDisplayedShortcuts($widget);- $widget.find("[data-trigger-event]").on('click', e => {- const eventName = $(e.target).attr('data-trigger-event');-- this.appContext.trigger(eventName);- });-this.toggle(this.isEnabled());return $widget;diff --git a/src/public/javascripts/widgets/note_tree.js b/src/public/javascripts/widgets/note_tree.jsindex 23f2728647..787b1464d3 100644--- a/src/public/javascripts/widgets/note_tree.js+++ b/src/public/javascripts/widgets/note_tree.js@@ -473,7 +473,7 @@ export default class NoteTreeWidget extends TabAwareWidget {this.tabManager.getActiveTabContext().setNote(notePath);}- node.remove();+ noteIdsToReload.add(branch.parentNoteId);}else {noteIdsToUpdate.add(branch.noteId);