Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(nbstore): fix doc clock check logic (#10355)

EYHN4a66ec74000f
diff --git a/packages/common/nbstore/src/sync/doc/peer.ts b/packages/common/nbstore/src/sync/doc/peer.ts
index 27048919c2..9cfdcb7e10 100644
--- a/packages/common/nbstore/src/sync/doc/peer.ts
+++ b/packages/common/nbstore/src/sync/doc/peer.ts
@@ -247,7 +247,7 @@ export class DocSyncPeer {
!this.remote.isReadonly &&
clock &&
(pushedClock === null ||
- pushedClock.getTime() !== clock.timestamp.getTime())
+ pushedClock.getTime() < clock.timestamp.getTime())
) {
await this.jobs.pullAndPush(docId, signal);
} else {
@@ -255,9 +255,10 @@ export class DocSyncPeer {
const pulled =
(await this.syncMetadata.getPeerPulledRemoteClock(this.peerId, docId))
?.timestamp ?? null;
+ const remoteClock = this.status.remoteClocks.get(docId);
if (
- pulled === null ||
- pulled.getTime() !== this.status.remoteClocks.get(docId)?.getTime()
+ remoteClock &&
+ (pulled === null || pulled.getTime() < remoteClock.getTime())
) {
await this.jobs.pull(docId, signal);
}