@@ -2,6 +2,7 @@ import FNote from "../../../entities/fnote";
22import contextMenu , { ContextMenuEvent } from "../../../menus/context_menu" ;
33import link_context_menu from "../../../menus/link_context_menu" ;
44import branches from "../../../services/branches" ;
5+ import froca from "../../../services/froca" ;
56import { t } from "../../../services/i18n" ;
67
78export 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