.
This commit is contained in:
parent
ca905ac1ce
commit
0c75d3b4c2
2 changed files with 11 additions and 8 deletions
|
|
@ -67,16 +67,17 @@ export class FileOperations {
|
|||
return snapshot.content;
|
||||
}
|
||||
|
||||
public async snapshot(path: string): Promise<StoredSnapshot | undefined> {
|
||||
const snapshot = await this.fs.read(path);
|
||||
return snapshot && toStoredSnapshot(snapshot);
|
||||
}
|
||||
|
||||
public async listFilesRecursively(): Promise<string[]> {
|
||||
return (await this.fs.listFilesRecursively()).filter(
|
||||
(path) => !isInternalPath(path)
|
||||
);
|
||||
}
|
||||
|
||||
public async snapshot(path: string): Promise<StoredSnapshot | undefined> {
|
||||
const snapshot = await this.fs.read(path);
|
||||
return snapshot && toStoredSnapshot(snapshot);
|
||||
}
|
||||
|
||||
public async captureChange(
|
||||
change: LocalChange,
|
||||
|
|
|
|||
|
|
@ -11,16 +11,18 @@ export type LocalChange = {
|
|||
| { type: "move"; oldPath: string; relativePath: string }
|
||||
| { type: "create"; path: string; documentId?: string }
|
||||
| { type: "delete"; path: string }
|
||||
);
|
||||
);
|
||||
|
||||
export function unappliedChanges<T extends { changeId?: string }>(
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue