@dabble/patches 0.7.20 → 0.7.22

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.
@@ -10,7 +10,7 @@ function mergeServerWithLocal(serverChanges, localOps) {
10
10
  const local = localByPath.get(serverOp.path);
11
11
  if (!local) return serverOp;
12
12
  const combiner = combinableOps[local.op];
13
- if (!combiner) return serverOp;
13
+ if (!combiner) return { ...serverOp, op: local.op, value: local.value };
14
14
  const mergedValue = combiner.apply(serverOp.value ?? 0, local.value ?? 0);
15
15
  const mergedOp = serverOp.op === "remove" ? "replace" : serverOp.op;
16
16
  return { ...serverOp, op: mergedOp, value: mergedValue };
@@ -55,10 +55,9 @@ class LWWAlgorithm {
55
55
  await this.store.applyServerChanges(docId, serverChanges);
56
56
  const sendingChange = await this.store.getSendingChange(docId);
57
57
  const pendingOps = await this.store.getPendingOps(docId);
58
- const localOps = [...sendingChange?.ops ?? [], ...pendingOps];
59
- const mergedChanges = mergeServerWithLocal(serverChanges, localOps);
58
+ const mergedChanges = mergeServerWithLocal(serverChanges, pendingOps);
60
59
  if (doc) {
61
- const hasPending = localOps.length > 0;
60
+ const hasPending = pendingOps.length > 0 || !!sendingChange;
62
61
  doc.applyChanges(mergedChanges, hasPending);
63
62
  }
64
63
  return mergedChanges;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.7.20",
3
+ "version": "0.7.22",
4
4
  "description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
5
5
  "author": "Jacob Wright <jacwright@gmail.com>",
6
6
  "bugs": {