Skip to content

Commit 1844a7d

Browse files
committed
fix(calendar): unable to delete in journal (closes #7702)
1 parent c9f648f commit 1844a7d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

apps/client/src/widgets/collections/calendar/context_menu.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import FNote from "../../../entities/fnote";
22
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
33
import link_context_menu from "../../../menus/link_context_menu";
44
import branches from "../../../services/branches";
5+
import froca from "../../../services/froca";
56
import { t } from "../../../services/i18n";
67

78
export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, parentNote: FNote) {
@@ -18,8 +19,20 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, par
1819
title: t("calendar_view.delete_note"),
1920
uiIcon: "bx bx-trash",
2021
handler: async () => {
21-
const branchId = parentNote.childToBranch[noteId];
22-
await branches.deleteNotes([ branchId ], false, false);
22+
const noteToDelete = await froca.getNote(noteId);
23+
if (!noteToDelete) return;
24+
25+
let branchIdToDelete: string | null = null;
26+
for (const parentBranch of noteToDelete.getParentBranches()) {
27+
const parentNote = await parentBranch.getNote();
28+
if (parentNote?.hasAncestor(parentNote.noteId)) {
29+
branchIdToDelete = parentBranch.branchId;
30+
}
31+
}
32+
33+
if (branchIdToDelete) {
34+
await branches.deleteNotes([ branchIdToDelete ], false, false);
35+
}
2336
}
2437
}
2538
],

0 commit comments

Comments
 (0)