cry-synced-db-client 0.1.63 → 0.1.64
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 +12 -3
- package/dist/src/db/types/managers.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2057,11 +2057,18 @@ class SyncEngine {
|
|
|
2057
2057
|
this.callOnFindNewerManyResult(syncSpecs, {}, findNewerManyStartTime, false, calledFrom, err);
|
|
2058
2058
|
throw err;
|
|
2059
2059
|
}
|
|
2060
|
+
const allUpdatedIds = {};
|
|
2060
2061
|
for (const [collectionName, config] of this.collections) {
|
|
2061
2062
|
const serverData = allServerData[collectionName] || [];
|
|
2062
2063
|
receivedCount += serverData.length;
|
|
2063
2064
|
const stats = await this.processIncomingServerData(collectionName, config, serverData);
|
|
2064
2065
|
conflictsResolved += stats.conflictsResolved;
|
|
2066
|
+
if (stats.updatedIds.length > 0) {
|
|
2067
|
+
allUpdatedIds[collectionName] = stats.updatedIds;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
if (Object.keys(allUpdatedIds).length > 0) {
|
|
2071
|
+
this.deps.broadcastUpdates(allUpdatedIds);
|
|
2065
2072
|
}
|
|
2066
2073
|
const uploadStats = await this.uploadDirtyItems(calledFrom);
|
|
2067
2074
|
sentCount = uploadStats.sentCount;
|
|
@@ -2274,7 +2281,7 @@ class SyncEngine {
|
|
|
2274
2281
|
}
|
|
2275
2282
|
async processIncomingServerData(collectionName, config, serverData) {
|
|
2276
2283
|
if (serverData.length === 0) {
|
|
2277
|
-
return { conflictsResolved: 0, maxTs: undefined };
|
|
2284
|
+
return { conflictsResolved: 0, maxTs: undefined, updatedIds: [] };
|
|
2278
2285
|
}
|
|
2279
2286
|
let maxTs;
|
|
2280
2287
|
let conflictsResolved = 0;
|
|
@@ -2335,7 +2342,8 @@ class SyncEngine {
|
|
|
2335
2342
|
lastSyncTs: maxTs
|
|
2336
2343
|
});
|
|
2337
2344
|
}
|
|
2338
|
-
|
|
2345
|
+
const updatedIds = serverIds.map((id) => String(id));
|
|
2346
|
+
return { conflictsResolved, maxTs, updatedIds };
|
|
2339
2347
|
}
|
|
2340
2348
|
compareTimestamps(a, b) {
|
|
2341
2349
|
const aT = typeof a === "object" && "t" in a ? a.t : 0;
|
|
@@ -2933,7 +2941,8 @@ class SyncedDb {
|
|
|
2933
2941
|
goOffline: (reason) => this.connectionManager.goOffline(reason),
|
|
2934
2942
|
flushAllPendingChanges: () => this.pendingChanges.flushAll(),
|
|
2935
2943
|
cancelRestUploadTimer: () => this.pendingChanges.cancelRestUploadTimer(),
|
|
2936
|
-
awaitRestUpload: () => this.pendingChanges.awaitRestUpload()
|
|
2944
|
+
awaitRestUpload: () => this.pendingChanges.awaitRestUpload(),
|
|
2945
|
+
broadcastUpdates: (updates) => this.crossTabSync.broadcastMetaUpdate(updates)
|
|
2937
2946
|
}
|
|
2938
2947
|
});
|
|
2939
2948
|
this.serverUpdateHandler = new ServerUpdateHandler({
|
|
@@ -223,6 +223,8 @@ export interface SyncEngineDeps {
|
|
|
223
223
|
flushAllPendingChanges: () => Promise<void>;
|
|
224
224
|
cancelRestUploadTimer: () => void;
|
|
225
225
|
awaitRestUpload: () => Promise<void>;
|
|
226
|
+
/** Broadcast updated IDs to other tabs */
|
|
227
|
+
broadcastUpdates: (updates: Record<string, string[]>) => void;
|
|
226
228
|
}
|
|
227
229
|
export interface SyncEngineConfig {
|
|
228
230
|
tenant: string;
|