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
feat(calendar): don't trigger refresh on delete
Elian Dorane51cea88bf59
diff --git a/apps/client/src/services/branches.ts b/apps/client/src/services/branches.tsindex cd1f5c6e70..8f31060242 100644--- a/apps/client/src/services/branches.ts+++ b/apps/client/src/services/branches.ts@@ -103,7 +103,7 @@ async function moveToParentNote(branchIdsToMove: string[], newParentBranchId: st* @param moveToParent whether to automatically go to the parent note path after a succesful delete. Usually makes sense if deleting the active note(s).* @returns promise that returns false if the operation was cancelled or there was nothing to delete, true if the operation succeeded.*/-async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = false, moveToParent = true) {+async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = false, moveToParent = true, componentId?: string) {branchIdsToDelete = filterRootNote(branchIdsToDelete);if (branchIdsToDelete.length === 0) {@@ -139,9 +139,9 @@ async function deleteNotes(branchIdsToDelete: string[], forceDeleteAllClones = fconst branch = froca.getBranch(branchIdToDelete);if (deleteAllClones && branch) {- await server.remove(`notes/${branch.noteId}${query}`);+ await server.remove(`notes/${branch.noteId}${query}`, componentId);} else {- await server.remove(`branches/${branchIdToDelete}${query}`);+ await server.remove(`branches/${branchIdToDelete}${query}`, componentId);}}diff --git a/apps/client/src/widgets/collections/calendar/context_menu.ts b/apps/client/src/widgets/collections/calendar/context_menu.tsindex 5b157567ed..8c3511c363 100644--- a/apps/client/src/widgets/collections/calendar/context_menu.ts+++ b/apps/client/src/widgets/collections/calendar/context_menu.ts@@ -1,12 +1,12 @@-import NoteColorPicker from "../../../menus/custom-items/NoteColorPicker";import FNote from "../../../entities/fnote";import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";+import { getArchiveMenuItem } from "../../../menus/context_menu_utils";+import NoteColorPicker from "../../../menus/custom-items/NoteColorPicker";import link_context_menu from "../../../menus/link_context_menu";import branches from "../../../services/branches";-import { getArchiveMenuItem } from "../../../menus/context_menu_utils";import { t } from "../../../services/i18n";-export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parentNote: FNote) {+export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parentNote: FNote, componentId?: string) {e.preventDefault();e.stopPropagation();@@ -30,16 +30,16 @@ export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parent}if (branchIdToDelete) {- await branches.deleteNotes([ branchIdToDelete ], false, false);+ await branches.deleteNotes([ branchIdToDelete ], false, false, componentId);}}},{ kind: "separator" },{kind: "custom",- componentFn: () => NoteColorPicker({note: note})+ componentFn: () => NoteColorPicker({note})}],selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, e, note.noteId),- })+ });}diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsxindex 7eb201b0c1..0bfaaf5b5b 100644--- a/apps/client/src/widgets/collections/calendar/index.tsx+++ b/apps/client/src/widgets/collections/calendar/index.tsx@@ -114,7 +114,7 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarViconst plugins = usePlugins(isEditable, isCalendarRoot);const locale = useLocale();- const { eventDidMount } = useEventDisplayCustomization(note);+ const { eventDidMount } = useEventDisplayCustomization(note, parentComponent?.componentId);const editingProps = useEditing(note, isEditable, isCalendarRoot, parentComponent?.componentId);// React to changes.@@ -126,7 +126,6 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarViif (loadResults.getAttributeRows(parentComponent?.componentId).some((a) => noteIds.includes(a.noteId ?? ""))) {// Defer execution after the load results are processed so that the event builder has the updated data to work with.setTimeout(() => {- console.log("Refresh");calendarRef.current?.refetchEvents();}, 0);return; // early return since we'll refresh the events anyway@@ -277,7 +276,7 @@ function useEditing(note: FNote, isEditable: boolean, isCalendarRoot: boolean, c};}-function useEventDisplayCustomization(parentNote: FNote) {+function useEventDisplayCustomization(parentNote: FNote, componentId: string | undefined) {const eventDidMount = useCallback((e: EventMountArg) => {const { iconClass, promotedAttributes } = e.event.extendedProps;@@ -334,7 +333,7 @@ function useEventDisplayCustomization(parentNote: FNote) {const note = await froca.getNote(e.event.extendedProps.noteId);if (!note) return;- openCalendarContextMenu(contextMenuEvent, note, parentNote);+ openCalendarContextMenu(contextMenuEvent, note, parentNote, componentId);}if (isMobile()) {