mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 21:06:22 +08:00
fix(nbstore): local doc update lost (#10422)
This commit is contained in:
@@ -399,31 +399,23 @@ export class DocFrontend {
|
|||||||
this.statusUpdatedSubject$.next(job.docId);
|
this.statusUpdatedSubject$.next(job.docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* skip listen doc update when apply update
|
|
||||||
*/
|
|
||||||
private skipDocUpdate = false;
|
|
||||||
|
|
||||||
applyUpdate(docId: string, update: Uint8Array) {
|
applyUpdate(docId: string, update: Uint8Array) {
|
||||||
const doc = this.status.docs.get(docId);
|
const doc = this.status.docs.get(docId);
|
||||||
if (doc && !isEmptyUpdate(update)) {
|
if (doc && !isEmptyUpdate(update)) {
|
||||||
try {
|
try {
|
||||||
this.skipDocUpdate = true;
|
|
||||||
applyUpdate(doc, update, NBSTORE_ORIGIN);
|
applyUpdate(doc, update, NBSTORE_ORIGIN);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('failed to apply update yjs doc', err);
|
console.error('failed to apply update yjs doc', err);
|
||||||
} finally {
|
|
||||||
this.skipDocUpdate = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly handleDocUpdate = (
|
private readonly handleDocUpdate = (
|
||||||
update: Uint8Array,
|
update: Uint8Array,
|
||||||
_origin: any,
|
origin: any,
|
||||||
doc: YDoc
|
doc: YDoc
|
||||||
) => {
|
) => {
|
||||||
if (this.skipDocUpdate) {
|
if (origin === NBSTORE_ORIGIN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.status.docs.has(doc.guid)) {
|
if (!this.status.docs.has(doc.guid)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user