diff options
author | Skitty1238 <157652284+Skitty1238@users.noreply.github.com> | 2025-06-09 10:38:07 -0400 |
---|---|---|
committer | Skitty1238 <157652284+Skitty1238@users.noreply.github.com> | 2025-06-09 10:38:07 -0400 |
commit | a91884435ea0fd9f1215c938c636551e42690e9d (patch) | |
tree | 13b1115d99da50a1fa8e078fb175d1f4d44df30d /src | |
parent | ee7da91564ae293f394b487f96c53f0118af9d7b (diff) |
Fix sync logic to avoid overwriting newer Dash edits with outdated Google versions
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/TaskBox.tsx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client/views/nodes/TaskBox.tsx b/src/client/views/nodes/TaskBox.tsx index 5f46c9b2c..d29160e02 100644 --- a/src/client/views/nodes/TaskBox.tsx +++ b/src/client/views/nodes/TaskBox.tsx @@ -239,7 +239,7 @@ export class TaskBox extends ViewBoxBaseComponent<FieldViewProps>() { }; /** - * Method to sync the task with Google Tasks bidirectionally + * Method to sync the task with Google Tasks bidirectionally * (update Dash from Google and vice versa, based on which is newer) * @param silent - whether to suppress UI prompts to connect to Google (default: false) * @returns - a promise that resolves to true if sync was successful, false otherwise @@ -290,7 +290,10 @@ export class TaskBox extends ViewBoxBaseComponent<FieldViewProps>() { const googleUpdated = new Date(googleTask.updated); const dashUpdated = new Date(StrCast(doc.$task_lastSyncedAt)); - if (googleUpdated > dashUpdated) { + const dashChanged = + StrCast(doc.title) !== this._lastSyncedTask.title || StrCast(doc[this.fieldKey]) !== this._lastSyncedTask.text || this.computeDueDate() !== this._lastSyncedTask.due || !!doc.$task_completed !== this._lastSyncedTask.completed; + + if (googleUpdated > dashUpdated && !dashChanged) { // Google version is newer — update Dash runInAction(() => { doc.title = googleTask.title ?? doc.title; @@ -315,6 +318,9 @@ export class TaskBox extends ViewBoxBaseComponent<FieldViewProps>() { console.log('Pulled newer version from Google'); return true; + } else if (googleUpdated <= dashUpdated && !dashChanged) { + console.log('No changes to sync'); + return true; } else { // Dash version is newer — push update to Google const body = this.buildGoogleTaskBody(); |