@jcbuisson/express-x-client 3.1.20 → 3.1.23
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/package.json +1 -1
- package/src/client.mts +8 -1
package/package.json
CHANGED
package/src/client.mts
CHANGED
|
@@ -293,7 +293,12 @@ export function offlinePlugin(app) {
|
|
|
293
293
|
async function applyDeleteAcknowledgement(uid, requestDeletedAt, result) {
|
|
294
294
|
const currentMetadata = await db.metadata.get(uid)
|
|
295
295
|
if (!currentMetadata || !sameTimestamp(currentMetadata.deleted_at, requestDeletedAt)) return
|
|
296
|
-
const [, meta] = Array.isArray(result) ? result : []
|
|
296
|
+
const [value, meta] = Array.isArray(result) ? result : []
|
|
297
|
+
if (value?.uid && !meta?.deleted_at) {
|
|
298
|
+
const restoredValue = { ...value }
|
|
299
|
+
delete restoredValue.__deleted__
|
|
300
|
+
await db.values.put(restoredValue)
|
|
301
|
+
}
|
|
297
302
|
if (meta?.uid)
|
|
298
303
|
await db.metadata.put({ ...meta, __dirty__: false })
|
|
299
304
|
else
|
|
@@ -525,6 +530,8 @@ export function offlinePlugin(app) {
|
|
|
525
530
|
// uid to Dexie between the idbValues.filter snapshot and this step,
|
|
526
531
|
// add() would throw ConstraintError and abort the entire transaction,
|
|
527
532
|
// silently dropping every other addClient record in the batch.
|
|
533
|
+
const currentMetadata = await idbMetadata.get(value.uid)
|
|
534
|
+
if (currentMetadata && compareMetadataTime(metaData, currentMetadata) <= 0) continue
|
|
528
535
|
await idbValues.put(value)
|
|
529
536
|
await idbMetadata.put({ ...metaData, __dirty__: false })
|
|
530
537
|
}
|