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): local doc update lost (#10422)

EYHNc644a46b8d14
diff --git a/packages/common/nbstore/src/frontend/doc.ts b/packages/common/nbstore/src/frontend/doc.ts
index 516a616b53..f5b6aa2dfc 100644
--- a/packages/common/nbstore/src/frontend/doc.ts
+++ b/packages/common/nbstore/src/frontend/doc.ts
@@ -399,31 +399,23 @@ export class DocFrontend {
this.statusUpdatedSubject$.next(job.docId);
}
- /**
- * skip listen doc update when apply update
- */
- private skipDocUpdate = false;
-
applyUpdate(docId: string, update: Uint8Array) {
const doc = this.status.docs.get(docId);
if (doc && !isEmptyUpdate(update)) {
try {
- this.skipDocUpdate = true;
applyUpdate(doc, update, NBSTORE_ORIGIN);
} catch (err) {
console.error('failed to apply update yjs doc', err);
- } finally {
- this.skipDocUpdate = false;
}
}
}
private readonly handleDocUpdate = (
update: Uint8Array,
- _origin: any,
+ origin: any,
doc: YDoc
) => {
- if (this.skipDocUpdate) {
+ if (origin === NBSTORE_ORIGIN) {
return;
}
if (!this.status.docs.has(doc.guid)) {