dexie-cloud-addon 4.0.1-beta.41 → 4.0.1-beta.43

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.
@@ -329,7 +329,10 @@ function listClientChanges(mutationTables, db, { since = {}, limit = Infinity }
329
329
  }));
330
330
  })));
331
331
  // Sort by time to get a true order of the operations (between tables)
332
- const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.ts - b.mut.ts);
332
+ const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.txid === b.mut.txid
333
+ ? a.mut.opNo - b.mut.opNo // Within same transaction, sort by opNo
334
+ : a.mut.ts - b.mut.ts // Different transactions - sort by timestamp when mutation resolved
335
+ );
333
336
  const result = [];
334
337
  let currentEntry = null;
335
338
  let currentTxid = null;
@@ -3131,6 +3134,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
3131
3134
  ? {
3132
3135
  type: 'insert',
3133
3136
  ts,
3137
+ opNo,
3134
3138
  keys,
3135
3139
  txid,
3136
3140
  userId,
@@ -3141,6 +3145,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
3141
3145
  // Common changeSpec for all keys
3142
3146
  type: 'modify',
3143
3147
  ts,
3148
+ opNo,
3144
3149
  keys,
3145
3150
  criteria: req.criteria,
3146
3151
  changeSpec: req.changeSpec,
@@ -3152,6 +3157,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
3152
3157
  // One changeSpec per key
3153
3158
  type: 'update',
3154
3159
  ts,
3160
+ opNo,
3155
3161
  keys: updates.keys,
3156
3162
  changeSpecs: updates.changeSpecs,
3157
3163
  txid,
@@ -3160,6 +3166,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
3160
3166
  : {
3161
3167
  type: 'upsert',
3162
3168
  ts,
3169
+ opNo,
3163
3170
  keys,
3164
3171
  values,
3165
3172
  txid,
@@ -4437,7 +4444,7 @@ function dexieCloud(dexie) {
4437
4444
  });
4438
4445
  const syncComplete = new Subject();
4439
4446
  dexie.cloud = {
4440
- version: '4.0.1-beta.41',
4447
+ version: '4.0.1-beta.43',
4441
4448
  options: Object.assign({}, DEFAULT_OPTIONS),
4442
4449
  schema: null,
4443
4450
  get currentUserId() {
@@ -4698,7 +4705,7 @@ function dexieCloud(dexie) {
4698
4705
  });
4699
4706
  }
4700
4707
  }
4701
- dexieCloud.version = '4.0.1-beta.41';
4708
+ dexieCloud.version = '4.0.1-beta.43';
4702
4709
  Dexie.Cloud = dexieCloud;
4703
4710
 
4704
4711
  // In case the SW lives for a while, let it reuse already opened connections: