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
  *
@@ -4007,7 +4007,7 @@ function MessagesFromServerConsumer(db) {
4007
4007
  event.next(null);
4008
4008
  }
4009
4009
  function consumeQueue() {
4010
- var _a, _b, _c;
4010
+ var _a, _b, _c, _d, _e, _f;
4011
4011
  return __awaiter(this, void 0, void 0, function* () {
4012
4012
  while (queue.length > 0) {
4013
4013
  const msg = queue.shift();
@@ -4039,29 +4039,32 @@ function MessagesFromServerConsumer(db) {
4039
4039
  // new token. So we don't need to do anything more here.
4040
4040
  break;
4041
4041
  case 'realm-added':
4042
- //if (!persistedSyncState?.realms?.includes(msg.realm) && !persistedSyncState?.inviteRealms?.includes(msg.realm)) {
4043
- triggerSync(db, 'pull');
4044
- //}
4042
+ if (!((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) &&
4043
+ !((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm))) {
4044
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4045
+ //triggerSync(db, 'pull');
4046
+ }
4045
4047
  break;
4046
4048
  case 'realm-accepted':
4047
- //if (!persistedSyncState?.realms?.includes(msg.realm)) {
4048
- triggerSync(db, 'pull');
4049
- //}
4049
+ if (!((_c = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _c === void 0 ? void 0 : _c.includes(msg.realm))) {
4050
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4051
+ //triggerSync(db, 'pull');
4052
+ }
4050
4053
  break;
4051
4054
  case 'realm-removed':
4052
- //if (
4053
- ((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) ||
4054
- ((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm));
4055
- //) {
4056
- triggerSync(db, 'pull');
4057
- //}
4055
+ if (((_d = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _d === void 0 ? void 0 : _d.includes(msg.realm)) ||
4056
+ ((_e = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _e === void 0 ? void 0 : _e.includes(msg.realm))) {
4057
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4058
+ //triggerSync(db, 'pull');
4059
+ }
4058
4060
  break;
4059
4061
  case 'realms-changed':
4060
- triggerSync(db, 'pull');
4062
+ //triggerSync(db, 'pull');
4063
+ yield db.cloud.sync({ purpose: 'pull', wait: true });
4061
4064
  break;
4062
4065
  case 'changes':
4063
4066
  console.debug('changes');
4064
- if (((_c = db.cloud.syncState.value) === null || _c === void 0 ? void 0 : _c.phase) === 'error') {
4067
+ if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
4065
4068
  triggerSync(db, 'pull');
4066
4069
  break;
4067
4070
  }
@@ -5186,10 +5189,13 @@ function connectWebSocket(db) {
5186
5189
  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
5187
5190
  switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
5188
5191
  filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
5189
- map((syncState) => ({
5190
- // Produce the message to trigger server to send us new messages to consume:
5191
- type: 'ready',
5192
- rev: syncState.serverRevision,
5192
+ switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
5193
+ return ({
5194
+ // Produce the message to trigger server to send us new messages to consume:
5195
+ type: 'ready',
5196
+ rev: syncState.serverRevision,
5197
+ realmSetHash: yield computeRealmSetHash(syncState)
5198
+ });
5193
5199
  })));
5194
5200
  function createObservable() {
5195
5201
  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.
@@ -6073,7 +6079,7 @@ function dexieCloud(dexie) {
6073
6079
  });
6074
6080
  const syncComplete = new Subject();
6075
6081
  dexie.cloud = {
6076
- version: '4.0.1-beta.39',
6082
+ version: '4.0.1-beta.40',
6077
6083
  options: Object.assign({}, DEFAULT_OPTIONS),
6078
6084
  schema: null,
6079
6085
  get currentUserId() {
@@ -6334,7 +6340,7 @@ function dexieCloud(dexie) {
6334
6340
  });
6335
6341
  }
6336
6342
  }
6337
- dexieCloud.version = '4.0.1-beta.39';
6343
+ dexieCloud.version = '4.0.1-beta.40';
6338
6344
  Dexie.Cloud = dexieCloud;
6339
6345
 
6340
6346
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };