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 event change
Elian Doran17b1f599ff9a
diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.tsindex 728ff515c6..2bff933244 100644--- a/apps/client/src/services/attributes.ts+++ b/apps/client/src/services/attributes.ts@@ -117,15 +117,15 @@ function removeOwnedRelationByName(note: FNote, relationName: string) {* @param name the name of the attribute to set.* @param value the value of the attribute to set.*/-export async function setAttribute(note: FNote, type: "label" | "relation", name: string, value: string | null | undefined) {+export async function setAttribute(note: FNote, type: "label" | "relation", name: string, value: string | null | undefined, componentId?: string) {if (value !== null && value !== undefined) {// Create or update the attribute.- await server.put(`notes/${note.noteId}/set-attribute`, { type, name, value });+ await server.put(`notes/${note.noteId}/set-attribute`, { type, name, value }, componentId);} else {// Remove the attribute if it exists on the server but we don't define a value for it.const attributeId = note.getAttribute(type, name)?.attributeId;if (attributeId) {- await server.remove(`notes/${note.noteId}/attributes/${attributeId}`);+ await server.remove(`notes/${note.noteId}/attributes/${attributeId}`, componentId);}}}diff --git a/apps/client/src/widgets/collections/calendar/api.ts b/apps/client/src/widgets/collections/calendar/api.tsindex fde9a26501..79df65e4c1 100644--- a/apps/client/src/widgets/collections/calendar/api.ts+++ b/apps/client/src/widgets/collections/calendar/api.ts@@ -18,6 +18,7 @@ interface ChangeEventOpts {endDate?: string | null;startTime?: string | null;endTime?: string | null;+ componentId?: string;}export async function newEvent(parentNote: FNote, { title, startDate, endDate, startTime, endTime, componentId }: NewEventOpts) {@@ -58,7 +59,7 @@ export async function newEvent(parentNote: FNote, { title, startDate, endDate, s}, componentId);}-export async function changeEvent(note: FNote, { startDate, endDate, startTime, endTime }: ChangeEventOpts) {+export async function changeEvent(note: FNote, { startDate, endDate, startTime, endTime, componentId }: ChangeEventOpts) {// Don't store the end date if it's empty.if (endDate === startDate) {endDate = undefined;@@ -70,12 +71,12 @@ export async function changeEvent(note: FNote, { startDate, endDate, startTime,let endAttribute = note.getAttributes("label").filter(attr => attr.name == "calendar:endDate").shift()?.value||"endDate";const noteId = note.noteId;- setLabel(noteId, startAttribute, startDate);- setAttribute(note, "label", endAttribute, endDate);+ setLabel(noteId, startAttribute, startDate, false, componentId);+ setAttribute(note, "label", endAttribute, endDate, componentId);startAttribute = note.getAttributes("label").filter(attr => attr.name == "calendar:startTime").shift()?.value||"startTime";endAttribute = note.getAttributes("label").filter(attr => attr.name == "calendar:endTime").shift()?.value||"endTime";- setAttribute(note, "label", startAttribute, startTime);- setAttribute(note, "label", endAttribute, endTime);+ setAttribute(note, "label", startAttribute, startTime, componentId);+ setAttribute(note, "label", endAttribute, endTime, componentId);}diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsxindex fd7669646e..0f14ee1552 100644--- a/apps/client/src/widgets/collections/calendar/index.tsx+++ b/apps/client/src/widgets/collections/calendar/index.tsx@@ -246,8 +246,8 @@ function useEditing(note: FNote, isEditable: boolean, isCalendarRoot: boolean, cconst { startTime, endTime } = parseStartEndTimeFromEvent(e.event);const note = await froca.getNote(e.event.extendedProps.noteId);if (!note) return;- changeEvent(note, { startDate, endDate, startTime, endTime });- }, []);+ changeEvent(note, { startDate, endDate, startTime, endTime, componentId });+ }, [ componentId ]);// Called upon when clicking the day number in the calendar, opens or creates the day note but only if in a calendar root.const onDateClick = useCallback(async (e: DateClickArg) => {