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
fix branch prefix dialog
zadam2fa41b44c515
diff --git a/src/public/javascripts/dialogs/branch_prefix.js b/src/public/javascripts/dialogs/branch_prefix.jsindex 6e123d8733..2c2c0e2d3f 100644--- a/src/public/javascripts/dialogs/branch_prefix.js+++ b/src/public/javascripts/dialogs/branch_prefix.js@@ -11,11 +11,17 @@ const $noteTitle = $('#branch-prefix-note-title');let branchId;-export async function showDialog(node) {- branchId = node.data.branchId;+export async function showDialog(notePath) {+ const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);++ if (!noteId || !parentNoteId) {+ return;+ }++ branchId = await treeCache.getBranchId(parentNoteId, noteId);const branch = treeCache.getBranch(branchId);- if (branch.noteId === 'root') {+ if (!branch || branch.noteId === 'root') {return;}@@ -29,7 +35,7 @@ export async function showDialog(node) {$treePrefixInput.val(branch.prefix);- const noteTitle = await treeService.getNoteTitle(node.data.noteId);+ const noteTitle = await treeService.getNoteTitle(noteId);$noteTitle.text(" - " + noteTitle);}@@ -39,8 +45,6 @@ async function savePrefix() {await server.put('branches/' + branchId + '/set-prefix', { prefix: prefix });- await treeService.setPrefix(branchId, prefix);-$dialog.modal('hide');toastService.showMessage("Branch prefix has been saved.");diff --git a/src/public/javascripts/services/dialog_events.js b/src/public/javascripts/services/dialog_events.jsindex 2aebb3a873..ba7b50caef 100644--- a/src/public/javascripts/services/dialog_events.js+++ b/src/public/javascripts/services/dialog_events.js@@ -52,11 +52,12 @@ export default class DialogEventComponent extends Component {}async editBranchPrefixListener() {- // FIXME- const node = this.appContext.getMainNoteTree().getActiveNode();+ const notePath = this.appContext.tabManager.getActiveTabNotePath();- const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");- editBranchPrefixDialog.showDialog(node);+ if (notePath) {+ const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");+ editBranchPrefixDialog.showDialog(notePath);+ }}addLinkToTextListener() {