rails-markup 1.4.1 → 1.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 665bd02a5e8830d8565296c7623f4136513a61a2c1574e68c0c2b6802daf7ea2
4
- data.tar.gz: fd6290208722a52ecc255f3d01cdf017de31010157f6c67cc4386423e848eb98
3
+ metadata.gz: 34e44f1b30e4c51432e862ee09efd9d1f72e906a41e0e38f9c7553267f737d6f
4
+ data.tar.gz: '0909684467d87ed6a1248657ea2fc0e120956b66203c55b47750e74b57971bcb'
5
5
  SHA512:
6
- metadata.gz: 32afe3f8d8ea940731cde32f9524738189ca7d54b1bc1d124adc8888adb9fce35347647bc5844ca15dac6c918a546cef2d9ca048e0901e98ebc87f17db34ec4e
7
- data.tar.gz: 2c173c2623816601f0cc5ab730960cc035f2523a14adad0de4d130163f358d47562959f8fbd6c4b9e2e2ea9a0442e6d711dc6ba35070d89ae7d23e17c6cb2b15
6
+ metadata.gz: ea571e4c90037645f9f81ddc6e95710ffd6333addee88f6b43b3352ee8be8bcf9afb9b4d0d2868965f30825c370bf668a6e3a61e7fe345c6ae2469e8e205216c
7
+ data.tar.gz: ec0f2ff1ae946b95e7e6c6a7c0fb90429faa8bab7e8cbe30763a09440056760ab9049aed14b296a36c52095f9c1eae5d45941c6a1ccae8bcc346e5f12d03a5d3
@@ -1197,6 +1197,8 @@
1197
1197
 
1198
1198
  if (result.kind === "success") {
1199
1199
  if (!this._outboxEntryMatches(snapshot)) {
1200
+ const supersedingDelete = this._advanceSupersedingDeleteBaseRevision(snapshot, result.data);
1201
+ if (supersedingDelete === "failed") break;
1200
1202
  clientIds.push(clientId);
1201
1203
  continue;
1202
1204
  }
@@ -1242,6 +1244,25 @@
1242
1244
  }
1243
1245
  },
1244
1246
 
1247
+ _advanceSupersedingDeleteBaseRevision(snapshot, server) {
1248
+ const current = this.outbox[snapshot.clientId];
1249
+ const supersedesUpsert = snapshot.type === "upsert"
1250
+ && current?.type === "delete"
1251
+ && current.clientId === snapshot.clientId
1252
+ && Number.isInteger(current.revision)
1253
+ && current.revision > snapshot.revision
1254
+ && Number.isInteger(server?.revision);
1255
+ if (!supersedesUpsert) return "not-applicable";
1256
+
1257
+ const tombstone = this._immutableCopy(current);
1258
+ const committed = this._commitLocalStateChange(() => {
1259
+ if (!this._outboxEntryMatches(tombstone)) return;
1260
+ const baseRevision = Number.isInteger(tombstone.baseRevision) ? tombstone.baseRevision : 0;
1261
+ this.outbox[snapshot.clientId].baseRevision = Math.max(baseRevision, server.revision);
1262
+ });
1263
+ return committed ? "advanced" : "failed";
1264
+ },
1265
+
1245
1266
  async _sendOutboxEntry(snapshot) {
1246
1267
  const request = this._sameOriginMutationRequest(`/annotations/${encodeURIComponent(snapshot.clientId)}`);
1247
1268
  if (!request) return { kind: "auth", message: "Sync unavailable: endpoint must be same-origin" };
@@ -1434,12 +1455,20 @@
1434
1455
  if (annotation) annotation.syncState = "failed";
1435
1456
  return;
1436
1457
  }
1458
+ if (!annotation) {
1459
+ entry.syncState = "failed";
1460
+ return;
1461
+ }
1462
+ // Recreate once from the complete desired browser state. Replaying a
1463
+ // narrow edit delta onto a new row can omit required fields and lose
1464
+ // the user's annotation to a permanent validation failure.
1465
+ annotation.dirtyFields = this._legacyDirtyFields(annotation);
1466
+ entry.annotation = this._desiredState(annotation);
1467
+ entry.dirtyFields = annotation.dirtyFields.slice();
1437
1468
  entry.baseRevision = 0;
1438
1469
  entry.missingConflictRebased = true;
1439
- if (annotation) {
1440
- annotation.serverId = null;
1441
- annotation.serverRevision = 0;
1442
- }
1470
+ annotation.serverId = null;
1471
+ annotation.serverRevision = 0;
1443
1472
  resolution = "retry";
1444
1473
  return;
1445
1474
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMarkup
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - InventList