cry-synced-db-client 0.1.17 → 0.1.18

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -371,11 +371,17 @@ class SyncedDb {
371
371
  return this.online && !this.forcedOffline;
372
372
  }
373
373
  forceOffline(forced) {
374
+ const wasForced = this.forcedOffline;
374
375
  this.forcedOffline = forced;
375
376
  if (forced) {
376
377
  this.stopAutoSync();
377
378
  } else if (this.online) {
378
379
  this.startAutoSync();
380
+ if (wasForced) {
381
+ this.sync("forceOffline released").catch((err) => {
382
+ console.error("Sync after forceOffline release failed:", err);
383
+ });
384
+ }
379
385
  }
380
386
  }
381
387
  isForcedOffline() {
@@ -669,7 +675,10 @@ class SyncedDb {
669
675
  }
670
676
  }
671
677
  async sync(calledFrom) {
672
- if (!this.isOnline() || this.syncLock)
678
+ if (this.forcedOffline) {
679
+ throw new Error("Cannot sync while in forced offline mode");
680
+ }
681
+ if (!this.online || this.syncLock)
673
682
  return;
674
683
  this.syncLock = true;
675
684
  this.syncing = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",