From bc7ae802c62949c841db13f9cf7e1e25ce391674 Mon Sep 17 00:00:00 2001 From: Christen Date: Tue, 27 Jan 2026 16:16:14 +0100 Subject: [PATCH] add DTSTART to recurrence rule on task creation to apply google calendar event correctly --- src/services/TaskService.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/services/TaskService.ts b/src/services/TaskService.ts index c93a3866..d7931d63 100644 --- a/src/services/TaskService.ts +++ b/src/services/TaskService.ts @@ -344,6 +344,27 @@ export class TaskService { icsEventId: taskData.icsEventId || undefined, }; + // Add DTSTART to recurrence rule if it doesn't have one + // This ensures Google Calendar sync works correctly from the start + if ( + completeTaskData.recurrence && + typeof completeTaskData.recurrence === "string" && + !completeTaskData.recurrence.includes("DTSTART:") + ) { + const tempTaskInfo: TaskInfo = { + ...completeTaskData, + title: title, + status: status, + priority: priority, + path: "", // Path not yet known, but not needed for DTSTART calculation + archived: false, + }; + const recurrenceWithDTSTART = addDTSTARTToRecurrenceRule(tempTaskInfo); + if (recurrenceWithDTSTART) { + completeTaskData.recurrence = recurrenceWithDTSTART; + } + } + const shouldAddTaskTag = this.plugin.settings.taskIdentificationMethod === "tag"; const taskTagForFrontmatter = shouldAddTaskTag ? this.plugin.settings.taskTag