Skip to content

Commit 4ecdc44

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/pr/1925' into HEAD
# Conflicts: # docs/releases/unreleased.md # src/services/TaskCalendarSyncService.ts
2 parents 48031ed + f1f73c3 commit 4ecdc44

6 files changed

Lines changed: 740 additions & 14 deletions

File tree

docs/releases/unreleased.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ Example:
3333
- Thanks to @martin-forge for reporting and contributing the fix.
3434
- (#1912) Fixed "Create subtask" inserting the full path of the parent task in the Projects field instead of using the normal Obsidian link text.
3535
- Thanks to @pkuehne for reporting and @benmartinek for confirming.
36+
- (#1921) Fixed Google Calendar and auto-archive side effects falling stale after direct task file edits.
37+
- Reconciles lifecycle-relevant frontmatter changes through the existing task file update event, with a first-run fingerprint baseline to avoid bulk startup API writes.
38+
- Periodic recovery also cleans up indexed Google Calendar events whose task files were deleted or replaced while TaskNotes was running.
39+
- Thanks to @martin-forge for reporting and contributing the fix.

src/bootstrap/pluginBootstrap.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { EVENT_USER_NOTICE, type UserNoticePayload } from "../core/userNotices";
5959
const tasknotesLogger = createTaskNotesLogger({ tag: "Bootstrap/PluginBootstrap" });
6060

6161
type FileDeletedEventData = { path: string; prevCache?: unknown };
62+
type FileUpdatedEventData = { path: string; file?: unknown; updatedTask?: TaskInfo };
6263

6364
type EditorWithCodeMirror = {
6465
cm?: unknown;
@@ -344,8 +345,30 @@ export function initializeServicesLazily(plugin: TaskNotesPlugin): void {
344345
plugin.taskCalendarSyncService = new (
345346
await import("../services/TaskCalendarSyncService")
346347
).TaskCalendarSyncService(plugin, plugin.googleCalendarService);
348+
await plugin.taskCalendarSyncService.initializeExternalFileReconciliation();
347349
plugin.taskCalendarSyncService.startRecoveryQueueProcessor();
348350

351+
plugin.registerEvent(
352+
plugin.emitter.on("file-updated", (data: FileUpdatedEventData) => {
353+
if (!plugin.taskCalendarSyncService || !data?.path) {
354+
return;
355+
}
356+
357+
plugin.taskCalendarSyncService
358+
.handleExternalTaskFileUpdated(data.path, data.updatedTask)
359+
.catch((error) => {
360+
tasknotesLogger.warn(
361+
"Failed to reconcile externally updated task with Google Calendar:",
362+
{
363+
category: "provider",
364+
operation: "reconcile-external-task-file-update",
365+
error: error,
366+
}
367+
);
368+
});
369+
})
370+
);
371+
349372
plugin.registerEvent(
350373
plugin.emitter.on("file-deleted", (data: FileDeletedEventData) => {
351374
if (!plugin.taskCalendarSyncService) {

0 commit comments

Comments
 (0)