@jcbuisson/express-x-client 3.1.23 → 3.1.27
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 +20 -0
package/package.json
CHANGED
package/src/client.mts
CHANGED
|
@@ -265,6 +265,11 @@ export function offlinePlugin(app) {
|
|
|
265
265
|
const currentMetadata = await db.metadata.get(uid)
|
|
266
266
|
if (!isCreateRequestStillCurrent(currentMetadata, requestCreatedAt)) return
|
|
267
267
|
const [value, meta] = Array.isArray(result) ? result : []
|
|
268
|
+
if (!value?.uid && meta?.deleted_at) {
|
|
269
|
+
await db.values.delete(uid)
|
|
270
|
+
await db.metadata.delete(uid)
|
|
271
|
+
return
|
|
272
|
+
}
|
|
268
273
|
if (value?.uid) await db.values.put(value)
|
|
269
274
|
if (meta?.uid)
|
|
270
275
|
await db.metadata.put({ ...meta, __dirty__: false })
|
|
@@ -283,6 +288,11 @@ export function offlinePlugin(app) {
|
|
|
283
288
|
const currentMetadata = await db.metadata.get(uid)
|
|
284
289
|
if (!currentMetadata || !sameTimestamp(currentMetadata.updated_at, requestUpdatedAt)) return
|
|
285
290
|
const [value, meta] = Array.isArray(result) ? result : []
|
|
291
|
+
if (!value?.uid && meta?.deleted_at) {
|
|
292
|
+
await db.values.delete(uid)
|
|
293
|
+
await db.metadata.delete(uid)
|
|
294
|
+
return
|
|
295
|
+
}
|
|
286
296
|
if (value?.uid) await db.values.put(value)
|
|
287
297
|
if (meta?.uid)
|
|
288
298
|
await db.metadata.put({ ...meta, __dirty__: false })
|
|
@@ -576,6 +586,11 @@ export function offlinePlugin(app) {
|
|
|
576
586
|
const serverMeta = Array.isArray(result) ? result[1] : null
|
|
577
587
|
currentMetadata = await idbMetadata.get(elt.uid)
|
|
578
588
|
if (!metadataUnchangedSinceRequest(currentMetadata, elt)) continue
|
|
589
|
+
if (Array.isArray(result) && !result[0]?.uid && serverMeta?.deleted_at) {
|
|
590
|
+
await idbValues.delete(elt.uid)
|
|
591
|
+
await idbMetadata.delete(elt.uid)
|
|
592
|
+
continue
|
|
593
|
+
}
|
|
579
594
|
if (serverMeta?.uid) await idbMetadata.put({ ...serverMeta, __dirty__: false })
|
|
580
595
|
else await idbMetadata.update(elt.uid, { __dirty__: false })
|
|
581
596
|
} catch(err) {
|
|
@@ -602,6 +617,11 @@ export function offlinePlugin(app) {
|
|
|
602
617
|
const serverMeta = Array.isArray(result) ? result[1] : null
|
|
603
618
|
currentMetadata = await idbMetadata.get(elt.uid)
|
|
604
619
|
if (!metadataUnchangedSinceRequest(currentMetadata, elt)) continue
|
|
620
|
+
if (Array.isArray(result) && !result[0]?.uid && serverMeta?.deleted_at) {
|
|
621
|
+
await idbValues.delete(elt.uid)
|
|
622
|
+
await idbMetadata.delete(elt.uid)
|
|
623
|
+
continue
|
|
624
|
+
}
|
|
605
625
|
if (serverMeta?.uid) await idbMetadata.put({ ...serverMeta, __dirty__: false })
|
|
606
626
|
else await idbMetadata.update(elt.uid, { __dirty__: false })
|
|
607
627
|
} catch(err) {
|