Skip to content

Commit 9a342d8

Browse files
committed
feat: 🎸 enable remote state out of sync check
1 parent cfe3d22 commit 9a342d8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/json-crdt-repo/session/EditSession.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ export class EditSession<N extends JsonNode = JsonNode<any>> {
118118
this.merge(<any>res.merge!);
119119
});
120120
}
121-
// if (res.cursorBehind) {
122-
// setTimeout(async () => {
123-
// if (!this._stopped) return;
124-
// const get = await this.repo.getIf({
125-
// id: this.id,
126-
// cursor: this.cursor
127-
// });
128-
// if (!this._stopped) return;
129-
// if (!get) return;
130-
// this.reset(<any>get.model);
131-
// }, 50);
132-
// }
121+
if (res.cursorBehind) {
122+
setTimeout(async () => {
123+
if (this._stopped) return;
124+
const get = await this.repo.getIf({
125+
id: this.id,
126+
cursor: this.cursor
127+
});
128+
if (this._stopped) return;
129+
if (!get) return;
130+
this.reset(<any>get.model);
131+
}, 50);
132+
}
133133
return {remote: res.remote};
134134
} else {
135135
const res = await this.repo.getIf({id: this.id, time: this.model.clock.time - 1, cursor: this.cursor});

0 commit comments

Comments
 (0)