Rename & make idempotent

This commit is contained in:
Andras Schmelczer 2025-03-20 21:19:41 +00:00
parent 9e05734c5f
commit 136514d33a
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -114,7 +114,7 @@ export class Database {
this.save();
}
public resetSyncState(): void {
public reset(): void {
this.documents = [];
this.lastSeenUpdateId = 0;
this.save();
@ -142,7 +142,9 @@ export class Database {
);
if (entry === undefined) {
throw new Error("Document not found by update promise");
// This method should be idempotent and tolerant of
// stragglers calling it after the databse has been reset.
return;
}
entry.updates = entry.updates.filter((update) => update !== promise);