diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.ts index 728ff515c..2bff93324 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.ts index fde9a2650..79df65e4c 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.tsx index fd7669646..0f14ee155 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, c const { 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) => {