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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.39, Wed Apr 26 2023
11
+ * Version 4.0.1-beta.40, Mon May 08 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -4014,7 +4014,7 @@
4014
4014
  event.next(null);
4015
4015
  }
4016
4016
  function consumeQueue() {
4017
- var _a, _b, _c;
4017
+ var _a, _b, _c, _d, _e, _f;
4018
4018
  return __awaiter(this, void 0, void 0, function* () {
4019
4019
  while (queue.length > 0) {
4020
4020
  const msg = queue.shift();
@@ -4046,29 +4046,32 @@
4046
4046
  // new token. So we don't need to do anything more here.
4047
4047
  break;
4048
4048
  case 'realm-added':
4049
- //if (!persistedSyncState?.realms?.includes(msg.realm) && !persistedSyncState?.inviteRealms?.includes(msg.realm)) {
4050
- triggerSync(db, 'pull');
4051
- //}
4049
+ if (!((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) &&
4050
+ !((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm))) {
4051
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4052
+ //triggerSync(db, 'pull');
4053
+ }
4052
4054
  break;
4053
4055
  case 'realm-accepted':
4054
- //if (!persistedSyncState?.realms?.includes(msg.realm)) {
4055
- triggerSync(db, 'pull');
4056
- //}
4056
+ if (!((_c = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _c === void 0 ? void 0 : _c.includes(msg.realm))) {
4057
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4058
+ //triggerSync(db, 'pull');
4059
+ }
4057
4060
  break;
4058
4061
  case 'realm-removed':
4059
- //if (
4060
- ((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) ||
4061
- ((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm));
4062
- //) {
4063
- triggerSync(db, 'pull');
4064
- //}
4062
+ if (((_d = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _d === void 0 ? void 0 : _d.includes(msg.realm)) ||
4063
+ ((_e = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _e === void 0 ? void 0 : _e.includes(msg.realm))) {
4064
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4065
+ //triggerSync(db, 'pull');
4066
+ }
4065
4067
  break;
4066
4068
  case 'realms-changed':
4067
- triggerSync(db, 'pull');
4069
+ //triggerSync(db, 'pull');
4070
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4068
4071
  break;
4069
4072
  case 'changes':
4070
4073
  console.debug('changes');
4071
- if (((_c = db.cloud.syncState.value) === null || _c === void 0 ? void 0 : _c.phase) === 'error') {
4074
+ if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
4072
4075
  triggerSync(db, 'pull');
4073
4076
  break;
4074
4077
  }
@@ -5193,10 +5196,13 @@
5193
5196
  const messageProducer = db.messageConsumer.readyToServe.pipe(filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
5194
5197
  switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
5195
5198
  filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
5196
- map((syncState) => ({
5197
- // Produce the message to trigger server to send us new messages to consume:
5198
- type: 'ready',
5199
- rev: syncState.serverRevision,
5199
+ switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
5200
+ return ({
5201
+ // Produce the message to trigger server to send us new messages to consume:
5202
+ type: 'ready',
5203
+ rev: syncState.serverRevision,
5204
+ realmSetHash: yield computeRealmSetHash(syncState)
5205
+ });
5200
5206
  })));
5201
5207
  function createObservable() {
5202
5208
  return db.cloud.persistedSyncState.pipe(filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
@@ -6080,7 +6086,7 @@
6080
6086
  });
6081
6087
  const syncComplete = new rxjs.Subject();
6082
6088
  dexie.cloud = {
6083
- version: '4.0.1-beta.39',
6089
+ version: '4.0.1-beta.40',
6084
6090
  options: Object.assign({}, DEFAULT_OPTIONS),
6085
6091
  schema: null,
6086
6092
  get currentUserId() {
@@ -6341,7 +6347,7 @@
6341
6347
  });
6342
6348
  }
6343
6349
  }
6344
- dexieCloud.version = '4.0.1-beta.39';
6350
+ dexieCloud.version = '4.0.1-beta.40';
6345
6351
  Dexie__default["default"].Cloud = dexieCloud;
6346
6352
 
6347
6353
  exports["default"] = dexieCloud;