From 0c75d3b4c2ba5b65b06a0a7ffb66b4de15a0a6d5 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 26 Sep 2026 20:43:31 +0100 Subject: [PATCH] . --- .../sync-client/src/file-operations/file-operations.ts | 9 +++++---- .../sync-client/src/sync-operations/local-changes.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/sync-client/src/file-operations/file-operations.ts b/frontend/sync-client/src/file-operations/file-operations.ts index 8625fde0..aec5791e 100644 --- a/frontend/sync-client/src/file-operations/file-operations.ts +++ b/frontend/sync-client/src/file-operations/file-operations.ts @@ -67,16 +67,17 @@ export class FileOperations { return snapshot.content; } + public async snapshot(path: string): Promise { + const snapshot = await this.fs.read(path); + return snapshot && toStoredSnapshot(snapshot); + } + public async listFilesRecursively(): Promise { return (await this.fs.listFilesRecursively()).filter( (path) => !isInternalPath(path) ); } - public async snapshot(path: string): Promise { - const snapshot = await this.fs.read(path); - return snapshot && toStoredSnapshot(snapshot); - } public async captureChange( change: LocalChange, diff --git a/frontend/sync-client/src/sync-operations/local-changes.ts b/frontend/sync-client/src/sync-operations/local-changes.ts index 641e7061..58fdf39e 100644 --- a/frontend/sync-client/src/sync-operations/local-changes.ts +++ b/frontend/sync-client/src/sync-operations/local-changes.ts @@ -8,19 +8,21 @@ export type LocalChange = { /** Identities at notification time, before a remote application can reuse paths. */ identities?: Record; } & ( - | { type: "move"; oldPath: string; relativePath: string } - | { type: "create"; path: string; documentId?: string } - | { type: "delete"; path: string } -); + | { type: "move"; oldPath: string; relativePath: string } + | { type: "create"; path: string; documentId?: string } + | { type: "delete"; path: string } + ); export function unappliedChanges( state: EngineState, changes: readonly T[] ): T[] { for (const change of changes) change.changeId ??= uuid(); + const applied = changes.findIndex( (change) => change.changeId === state.lastAppliedLocalChangeId ); + return changes.slice(applied + 1); }