cry-synced-db-client 0.1.108 → 0.1.110

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.
package/dist/index.js CHANGED
@@ -3650,6 +3650,7 @@ var SyncedDb = class _SyncedDb {
3650
3650
  );
3651
3651
  }
3652
3652
  await this._loadLastFullSync();
3653
+ await this._loadLastInitialSync();
3653
3654
  await this.pendingChanges.recoverPendingWrites();
3654
3655
  const allowedColls = [...this.collections.keys()].filter((n) => this.isSyncAllowed(n));
3655
3656
  const dexieStart = Date.now();
@@ -3739,6 +3740,30 @@ var SyncedDb = class _SyncedDb {
3739
3740
  /** @internal Clear on dropDatabase */
3740
3741
  _clearLastFullSync() {
3741
3742
  this._lastFullSyncDate = void 0;
3743
+ this._lastInitialSyncDate = void 0;
3744
+ }
3745
+ /**
3746
+ * Returns when the initial sync (first full sync after login)
3747
+ * last completed, or undefined if never.
3748
+ * Persisted in Dexie via syncMeta key `__lastInitialSync`.
3749
+ */
3750
+ lastInitialSync() {
3751
+ return this._lastInitialSyncDate;
3752
+ }
3753
+ /** @internal Update after initial sync completes */
3754
+ async _setLastInitialSync(date) {
3755
+ this._lastInitialSyncDate = date;
3756
+ await this.dexieDb.setSyncMeta(
3757
+ "__lastInitialSync",
3758
+ date.toISOString()
3759
+ );
3760
+ }
3761
+ /** @internal Load cached value from Dexie */
3762
+ async _loadLastInitialSync() {
3763
+ const meta = await this.dexieDb.getSyncMeta("__lastInitialSync");
3764
+ if (meta == null ? void 0 : meta.lastSyncTs) {
3765
+ this._lastInitialSyncDate = new Date(meta.lastSyncTs);
3766
+ }
3742
3767
  }
3743
3768
  async close() {
3744
3769
  var _a, _b;
@@ -4243,6 +4268,11 @@ var SyncedDb = class _SyncedDb {
4243
4268
  await this.syncEngine.sync(calledFrom);
4244
4269
  if (!this.syncOnlyCollections) {
4245
4270
  const now = /* @__PURE__ */ new Date();
4271
+ if (!this._lastFullSyncDate) {
4272
+ this._setLastInitialSync(now).catch((err) => {
4273
+ console.error("Failed to persist lastInitialSync:", err);
4274
+ });
4275
+ }
4246
4276
  this._setLastFullSync(now).catch((err) => {
4247
4277
  console.error("Failed to persist lastFullSync:", err);
4248
4278
  });
@@ -78,6 +78,7 @@ export declare class SyncedDb implements I_SyncedDb {
78
78
  */
79
79
  flush(): Promise<void>;
80
80
  private _lastFullSyncDate?;
81
+ private _lastInitialSyncDate?;
81
82
  /**
82
83
  * Returns when all collections were last successfully synced
83
84
  * from the server, or undefined if never.
@@ -92,6 +93,16 @@ export declare class SyncedDb implements I_SyncedDb {
92
93
  private _loadLastFullSync;
93
94
  /** @internal Clear on dropDatabase */
94
95
  private _clearLastFullSync;
96
+ /**
97
+ * Returns when the initial sync (first full sync after login)
98
+ * last completed, or undefined if never.
99
+ * Persisted in Dexie via syncMeta key `__lastInitialSync`.
100
+ */
101
+ lastInitialSync(): Date | undefined;
102
+ /** @internal Update after initial sync completes */
103
+ _setLastInitialSync(date: Date): Promise<void>;
104
+ /** @internal Load cached value from Dexie */
105
+ private _loadLastInitialSync;
95
106
  close(): Promise<void>;
96
107
  isOnline(): boolean;
97
108
  forceOffline(forced: boolean): void;
@@ -489,6 +489,12 @@ export interface I_SyncedDb {
489
489
  * Cleared on dropDatabase().
490
490
  */
491
491
  lastSuccessfulServerSync(): Date | undefined;
492
+ /**
493
+ * Returns when the initial sync (first full sync after login/reload)
494
+ * last completed, or undefined if never.
495
+ * Persisted in Dexie via syncMeta key `__lastInitialSync`.
496
+ */
497
+ lastInitialSync(): Date | undefined;
492
498
  /** Ali je povezan na server */
493
499
  isOnline(): boolean;
494
500
  /** Nastavi online/offline status. Returns a promise when going online. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.108",
3
+ "version": "0.1.110",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",