@abraca/dabra 2.25.0 → 2.26.0
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.
|
@@ -15961,9 +15961,9 @@ function patchEntry(treeMap, id, patch, removeKeys = [], opts = {}) {
|
|
|
15961
15961
|
/**
|
|
15962
15962
|
* TreeTimestamps
|
|
15963
15963
|
*
|
|
15964
|
-
* Attaches an
|
|
15965
|
-
*
|
|
15966
|
-
*
|
|
15964
|
+
* Attaches an afterTransaction observer on a child Y.Doc so that whenever a
|
|
15965
|
+
* LOCAL edit is made, the `updatedAt` timestamp on the corresponding entry
|
|
15966
|
+
* in the root doc's `doc-tree` map is written.
|
|
15967
15967
|
*
|
|
15968
15968
|
* This propagates "last edited" timestamps to all peers via the root CRDT,
|
|
15969
15969
|
* without requiring any server-side changes.
|
|
@@ -15974,7 +15974,7 @@ function patchEntry(treeMap, id, patch, removeKeys = [], opts = {}) {
|
|
|
15974
15974
|
*/
|
|
15975
15975
|
/**
|
|
15976
15976
|
* Attach an observer that writes `updatedAt` to the root doc-tree entry for
|
|
15977
|
-
* `childDocId` whenever the child doc receives a
|
|
15977
|
+
* `childDocId` whenever the child doc receives a local edit.
|
|
15978
15978
|
*
|
|
15979
15979
|
* @param treeMap The root doc's "doc-tree" Y.Map.
|
|
15980
15980
|
* @param childDocId The child document's UUID (key in treeMap).
|
|
@@ -16004,8 +16004,10 @@ function attachUpdatedAtObserver(treeMap, childDocId, childDoc, offlineStore, op
|
|
|
16004
16004
|
pendingTs = 0;
|
|
16005
16005
|
writeTs(ts);
|
|
16006
16006
|
}
|
|
16007
|
-
function handler(
|
|
16008
|
-
if (
|
|
16007
|
+
function handler(tr) {
|
|
16008
|
+
if (!tr.local) return;
|
|
16009
|
+
if (offlineStore !== null && tr.origin === offlineStore) return;
|
|
16010
|
+
if (tr.changed.size === 0) return;
|
|
16009
16011
|
const now = Date.now();
|
|
16010
16012
|
if (now - lastFlushedAt >= throttleMs) {
|
|
16011
16013
|
writeTs(now);
|
|
@@ -16014,9 +16016,9 @@ function attachUpdatedAtObserver(treeMap, childDocId, childDoc, offlineStore, op
|
|
|
16014
16016
|
pendingTs = now;
|
|
16015
16017
|
if (timer === null) timer = setTimeout(flushPending, throttleMs - (now - lastFlushedAt));
|
|
16016
16018
|
}
|
|
16017
|
-
childDoc.on("
|
|
16019
|
+
childDoc.on("afterTransaction", handler);
|
|
16018
16020
|
return () => {
|
|
16019
|
-
childDoc.off("
|
|
16021
|
+
childDoc.off("afterTransaction", handler);
|
|
16020
16022
|
if (timer !== null) {
|
|
16021
16023
|
clearTimeout(timer);
|
|
16022
16024
|
flushPending();
|