From 1844a7d66683b27738a219dbac9698e7b1fd7182 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 15 Nov 2025 22:43:35 +0200 Subject: [PATCH] fix(calendar): unable to delete in journal (closes #7702) --- .../collections/calendar/context_menu.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/collections/calendar/context_menu.ts b/apps/client/src/widgets/collections/calendar/context_menu.ts index 7eddbed3c..b15ba376d 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, par title: 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); + } } } ],