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(calendar): unable to delete in journal (closes #7702)
Elian Doran1844a7d66683
diff --git a/apps/client/src/widgets/collections/calendar/context_menu.ts b/apps/client/src/widgets/collections/calendar/context_menu.tsindex 7eddbed3ca..b15ba376d1 100644--- a/apps/client/src/widgets/collections/calendar/context_menu.ts+++ b/apps/client/src/widgets/collections/calendar/context_menu.ts@@ -2,6 +2,7 @@ import FNote from "../../../entities/fnote";import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";import link_context_menu from "../../../menus/link_context_menu";import branches from "../../../services/branches";+import froca from "../../../services/froca";import { t } from "../../../services/i18n";export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, parentNote: FNote) {@@ -18,8 +19,20 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, partitle: t("calendar_view.delete_note"),uiIcon: "bx bx-trash",handler: async () => {- const branchId = parentNote.childToBranch[noteId];- await branches.deleteNotes([ branchId ], false, false);+ const noteToDelete = await froca.getNote(noteId);+ if (!noteToDelete) return;++ let branchIdToDelete: string | null = null;+ for (const parentBranch of noteToDelete.getParentBranches()) {+ const parentNote = await parentBranch.getNote();+ if (parentNote?.hasAncestor(parentNote.noteId)) {+ branchIdToDelete = parentBranch.branchId;+ }+ }++ if (branchIdToDelete) {+ await branches.deleteNotes([ branchIdToDelete ], false, false);+ }}}],