@jcbuisson/express-x-client 3.1.23 → 3.1.26

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/package.json +1 -1
  2. package/src/client.mts +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "3.1.23",
3
+ "version": "3.1.26",
4
4
  "type": "module",
5
5
  "description": "Client library for ExpressX framework",
6
6
  "main": "src/client.mts",
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 })
@@ -576,6 +581,11 @@ export function offlinePlugin(app) {
576
581
  const serverMeta = Array.isArray(result) ? result[1] : null
577
582
  currentMetadata = await idbMetadata.get(elt.uid)
578
583
  if (!metadataUnchangedSinceRequest(currentMetadata, elt)) continue
584
+ if (Array.isArray(result) && !result[0]?.uid && serverMeta?.deleted_at) {
585
+ await idbValues.delete(elt.uid)
586
+ await idbMetadata.delete(elt.uid)
587
+ continue
588
+ }
579
589
  if (serverMeta?.uid) await idbMetadata.put({ ...serverMeta, __dirty__: false })
580
590
  else await idbMetadata.update(elt.uid, { __dirty__: false })
581
591
  } catch(err) {