Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/releases/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ Example:

## Fixed

- (#1696) Fixed Google Calendar export for scheduled recurring tasks when a single occurrence is moved to a different date.
- Keeps the recurring master event on its original rule, excludes the original occurrence date, and syncs the moved occurrence as a detached event.

- (#1911) Fixed recurrence choices starting from today instead of the selected calendar date when creating a task from Calendar view.
- Thanks to @mikhailmarka for reporting.
17 changes: 15 additions & 2 deletions src/bootstrap/pluginBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,27 @@ export function initializeServicesLazily(plugin: TaskNotesPlugin): void {

const eventIdKey =
plugin.fieldMapper.toUserField("googleCalendarEventId");
const exceptionEventIdKey = plugin.fieldMapper.toUserField(
"googleCalendarExceptionEventId"
);
const prevCache = data.prevCache as
| { frontmatter?: Record<string, unknown> }
| undefined;
const eventId = prevCache?.frontmatter?.[eventIdKey];
const exceptionEventId = prevCache?.frontmatter?.[exceptionEventIdKey];

if (typeof eventId === "string" && eventId.length > 0) {
if (
(typeof eventId === "string" && eventId.length > 0) ||
(typeof exceptionEventId === "string" && exceptionEventId.length > 0)
) {
plugin.taskCalendarSyncService
.deleteTaskFromCalendarByPath(data.path, eventId)
.deleteTaskFromCalendarByPath(
data.path,
typeof eventId === "string" ? eventId : undefined,
typeof exceptionEventId === "string"
? exceptionEventId
: undefined
)
.catch((error) => {
tasknotesLogger.warn(
"Failed to delete task from Google Calendar on file deletion:",
Expand Down
3 changes: 3 additions & 0 deletions src/core/defaultFieldMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const DEFAULT_FIELD_MAPPING: FieldMapping = {
icsEventId: "icsEventId",
icsEventTag: "ics_event",
googleCalendarEventId: "googleCalendarEventId",
googleCalendarExceptionEventId: "googleCalendarExceptionEventId",
googleCalendarExceptionOriginalScheduled: "googleCalendarExceptionOriginalScheduled",
googleCalendarMovedOriginalDates: "googleCalendarMovedOriginalDates",
reminders: "reminders",
sortOrder: "tasknotes_manual_order",
};
40 changes: 40 additions & 0 deletions src/core/fieldMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ export function mapTaskFromFrontmatter(
);
}

if (frontmatter[mapping.googleCalendarExceptionEventId] !== undefined) {
mapped.googleCalendarExceptionEventId = normalizeStringValue(
frontmatter[mapping.googleCalendarExceptionEventId]
);
}

if (frontmatter[mapping.googleCalendarExceptionOriginalScheduled] !== undefined) {
mapped.googleCalendarExceptionOriginalScheduled = normalizeStringValue(
frontmatter[mapping.googleCalendarExceptionOriginalScheduled]
);
}

if (frontmatter[mapping.googleCalendarMovedOriginalDates] !== undefined) {
mapped.googleCalendarMovedOriginalDates = normalizeStringArrayValue(
frontmatter[mapping.googleCalendarMovedOriginalDates]
);
}

if (frontmatter[mapping.reminders] !== undefined) {
mapped.reminders = normalizeReminders(frontmatter[mapping.reminders]);
}
Expand Down Expand Up @@ -413,6 +431,28 @@ export function mapTaskToFrontmatter(
frontmatter[mapping.icsEventId] = taskData.icsEventId;
}

if (taskData.googleCalendarEventId !== undefined) {
frontmatter[mapping.googleCalendarEventId] = taskData.googleCalendarEventId;
}

if (taskData.googleCalendarExceptionEventId !== undefined) {
frontmatter[mapping.googleCalendarExceptionEventId] =
taskData.googleCalendarExceptionEventId;
}

if (taskData.googleCalendarExceptionOriginalScheduled !== undefined) {
frontmatter[mapping.googleCalendarExceptionOriginalScheduled] =
taskData.googleCalendarExceptionOriginalScheduled;
}

if (
taskData.googleCalendarMovedOriginalDates !== undefined &&
taskData.googleCalendarMovedOriginalDates.length > 0
) {
frontmatter[mapping.googleCalendarMovedOriginalDates] =
taskData.googleCalendarMovedOriginalDates;
}

if (taskData.reminders !== undefined && taskData.reminders.length > 0) {
frontmatter[mapping.reminders] = taskData.reminders;
}
Expand Down
6 changes: 6 additions & 0 deletions src/services/MdbaseSpecService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ export class MdbaseSpecService {
items: { type: "string" },
});
this.addRoleField(lines, "googleCalendarEventId", { type: "string" });
this.addRoleField(lines, "googleCalendarExceptionEventId", { type: "string" });
this.addRoleField(lines, "googleCalendarExceptionOriginalScheduled", { type: "date" });
this.addRoleField(lines, "googleCalendarMovedOriginalDates", {
type: "list",
items: { type: "date" },
});

// User-defined fields
if (settings.userFields && settings.userFields.length > 0) {
Expand Down
Loading
Loading