dexie-cloud-addon 4.0.1-beta.39 → 4.0.1-beta.40

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.
@@ -2146,7 +2146,7 @@
2146
2146
  event.next(null);
2147
2147
  }
2148
2148
  function consumeQueue() {
2149
- var _a, _b, _c;
2149
+ var _a, _b, _c, _d, _e, _f;
2150
2150
  return __awaiter(this, void 0, void 0, function* () {
2151
2151
  while (queue.length > 0) {
2152
2152
  const msg = queue.shift();
@@ -2178,29 +2178,32 @@
2178
2178
  // new token. So we don't need to do anything more here.
2179
2179
  break;
2180
2180
  case 'realm-added':
2181
- //if (!persistedSyncState?.realms?.includes(msg.realm) && !persistedSyncState?.inviteRealms?.includes(msg.realm)) {
2182
- triggerSync(db, 'pull');
2183
- //}
2181
+ if (!((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) &&
2182
+ !((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm))) {
2183
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
2184
+ //triggerSync(db, 'pull');
2185
+ }
2184
2186
  break;
2185
2187
  case 'realm-accepted':
2186
- //if (!persistedSyncState?.realms?.includes(msg.realm)) {
2187
- triggerSync(db, 'pull');
2188
- //}
2188
+ if (!((_c = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _c === void 0 ? void 0 : _c.includes(msg.realm))) {
2189
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
2190
+ //triggerSync(db, 'pull');
2191
+ }
2189
2192
  break;
2190
2193
  case 'realm-removed':
2191
- //if (
2192
- ((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) ||
2193
- ((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm));
2194
- //) {
2195
- triggerSync(db, 'pull');
2196
- //}
2194
+ if (((_d = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _d === void 0 ? void 0 : _d.includes(msg.realm)) ||
2195
+ ((_e = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _e === void 0 ? void 0 : _e.includes(msg.realm))) {
2196
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
2197
+ //triggerSync(db, 'pull');
2198
+ }
2197
2199
  break;
2198
2200
  case 'realms-changed':
2199
- triggerSync(db, 'pull');
2201
+ //triggerSync(db, 'pull');
2202
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
2200
2203
  break;
2201
2204
  case 'changes':
2202
2205
  console.debug('changes');
2203
- if (((_c = db.cloud.syncState.value) === null || _c === void 0 ? void 0 : _c.phase) === 'error') {
2206
+ if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
2204
2207
  triggerSync(db, 'pull');
2205
2208
  break;
2206
2209
  }
@@ -3554,10 +3557,13 @@
3554
3557
  const messageProducer = db.messageConsumer.readyToServe.pipe(operators.filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
3555
3558
  operators.switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
3556
3559
  operators.filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
3557
- operators.map((syncState) => ({
3558
- // Produce the message to trigger server to send us new messages to consume:
3559
- type: 'ready',
3560
- rev: syncState.serverRevision,
3560
+ operators.switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
3561
+ return ({
3562
+ // Produce the message to trigger server to send us new messages to consume:
3563
+ type: 'ready',
3564
+ rev: syncState.serverRevision,
3565
+ realmSetHash: yield computeRealmSetHash(syncState)
3566
+ });
3561
3567
  })));
3562
3568
  function createObservable() {
3563
3569
  return db.cloud.persistedSyncState.pipe(operators.filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
@@ -4434,7 +4440,7 @@
4434
4440
  });
4435
4441
  const syncComplete = new rxjs.Subject();
4436
4442
  dexie.cloud = {
4437
- version: '4.0.1-beta.39',
4443
+ version: '4.0.1-beta.40',
4438
4444
  options: Object.assign({}, DEFAULT_OPTIONS),
4439
4445
  schema: null,
4440
4446
  get currentUserId() {
@@ -4695,7 +4701,7 @@
4695
4701
  });
4696
4702
  }
4697
4703
  }
4698
- dexieCloud.version = '4.0.1-beta.39';
4704
+ dexieCloud.version = '4.0.1-beta.40';
4699
4705
  Dexie__default["default"].Cloud = dexieCloud;
4700
4706
 
4701
4707
  // In case the SW lives for a while, let it reuse already opened connections: