@hocuspocus/provider 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hocuspocus-provider.cjs +9 -2
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +9 -2
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +6 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +11 -2
- package/src/MessageReceiver.ts +1 -1
|
@@ -1806,7 +1806,7 @@ class MessageReceiver {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
if (syncMessageType === messageYjsUpdate || syncMessageType === messageYjsSyncStep2) {
|
|
1808
1808
|
if (provider.unsyncedChanges > 0) {
|
|
1809
|
-
provider.
|
|
1809
|
+
provider.updateUnsyncedChanges(-1);
|
|
1810
1810
|
}
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
@@ -2403,6 +2403,10 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2403
2403
|
get hasUnsyncedChanges() {
|
|
2404
2404
|
return this.unsyncedChanges > 0;
|
|
2405
2405
|
}
|
|
2406
|
+
updateUnsyncedChanges(unsyncedChanges = 0) {
|
|
2407
|
+
this.unsyncedChanges += unsyncedChanges;
|
|
2408
|
+
this.emit('unsyncedChanges', this.unsyncedChanges);
|
|
2409
|
+
}
|
|
2406
2410
|
forceSync() {
|
|
2407
2411
|
this.send(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name });
|
|
2408
2412
|
}
|
|
@@ -2422,7 +2426,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2422
2426
|
if (origin === this) {
|
|
2423
2427
|
return;
|
|
2424
2428
|
}
|
|
2425
|
-
this.
|
|
2429
|
+
this.updateUnsyncedChanges(1);
|
|
2426
2430
|
this.send(UpdateMessage, { update, documentName: this.configuration.name }, true);
|
|
2427
2431
|
}
|
|
2428
2432
|
awarenessUpdateHandler({ added, updated, removed }, origin) {
|
|
@@ -2440,6 +2444,9 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2440
2444
|
if (this.isSynced === state) {
|
|
2441
2445
|
return;
|
|
2442
2446
|
}
|
|
2447
|
+
if (state && this.unsyncedChanges > 0) {
|
|
2448
|
+
this.updateUnsyncedChanges(-1 * this.unsyncedChanges);
|
|
2449
|
+
}
|
|
2443
2450
|
this.isSynced = state;
|
|
2444
2451
|
this.emit('synced', { state });
|
|
2445
2452
|
this.emit('sync', { state });
|