@jcbuisson/express-x-client 3.1.0 → 3.1.2
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 +13 -16
package/package.json
CHANGED
package/src/client.mts
CHANGED
|
@@ -153,19 +153,18 @@ export async function reloadPlugin(app) {
|
|
|
153
153
|
const prevSocketId = cnxid.value
|
|
154
154
|
if (prevSocketId) {
|
|
155
155
|
console.log('cnx-transfer', prevSocketId, 'to', socketId)
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
socket.once('cnx-transfer-ack', async (fromSocketId, toSocketId) => {
|
|
157
|
+
console.log('ACK ACK!!!', fromSocketId, toSocketId)
|
|
158
|
+
cnxid.value = socketId
|
|
159
|
+
})
|
|
160
|
+
socket.once('cnx-transfer-error', async (fromSocketId, toSocketId) => {
|
|
161
|
+
console.log('ERR ERR!!!', fromSocketId, toSocketId)
|
|
162
|
+
cnxid.value = socketId
|
|
163
|
+
})
|
|
164
|
+
socket.emit('cnx-transfer', prevSocketId, socketId)
|
|
158
165
|
} else {
|
|
159
166
|
cnxid.value = socketId
|
|
160
167
|
}
|
|
161
|
-
|
|
162
|
-
socket.on('cnx-transfer-ack', async (fromSocketId, toSocketId) => {
|
|
163
|
-
console.log('ACK ACK!!!', fromSocketId, toSocketId)
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
socket.on('cnx-transfer-error', async (fromSocketId, toSocketId) => {
|
|
167
|
-
console.log('ERR ERR!!!', fromSocketId, toSocketId)
|
|
168
|
-
})
|
|
169
168
|
})
|
|
170
169
|
}
|
|
171
170
|
|
|
@@ -316,7 +315,7 @@ export function offlinePlugin(app) {
|
|
|
316
315
|
|
|
317
316
|
function addSynchroWhere(where: object) {
|
|
318
317
|
const promise = addSynchroDBWhere(where, db.whereList)
|
|
319
|
-
promise.then(isNew => isNew &&
|
|
318
|
+
promise.then(isNew => isNew && console.log(`addSynchroWhere (${++count})`, dbName, modelName, where))
|
|
320
319
|
return promise
|
|
321
320
|
}
|
|
322
321
|
|
|
@@ -437,14 +436,13 @@ export function offlinePlugin(app) {
|
|
|
437
436
|
// assigned, so checking fullValue == null afterwards is too late.
|
|
438
437
|
if (elt.uid == null) continue
|
|
439
438
|
const fullValue = await idbValues.get(elt.uid)
|
|
440
|
-
const meta = await idbMetadata.get(elt.uid)
|
|
441
439
|
if (fullValue == null) continue // record deleted concurrently
|
|
442
440
|
delete fullValue.uid
|
|
443
441
|
delete fullValue.__deleted__
|
|
444
442
|
try {
|
|
445
|
-
await app.service(modelName).createWithMeta(elt.uid, fullValue,
|
|
443
|
+
await app.service(modelName).createWithMeta(elt.uid, fullValue, elt.created_at)
|
|
446
444
|
} catch(err) {
|
|
447
|
-
console.log("*** err sync user addDatabase", err, elt.uid, fullValue,
|
|
445
|
+
console.log("*** err sync user addDatabase", err, elt.uid, fullValue, elt.created_at)
|
|
448
446
|
// rollback
|
|
449
447
|
await idbValues.delete(elt.uid)
|
|
450
448
|
await idbMetadata.delete(elt.uid)
|
|
@@ -455,12 +453,11 @@ export function offlinePlugin(app) {
|
|
|
455
453
|
for (const elt of updateDatabase) {
|
|
456
454
|
if (elt.uid == null) continue
|
|
457
455
|
const fullValue = await idbValues.get(elt.uid)
|
|
458
|
-
const meta = await idbMetadata.get(elt.uid)
|
|
459
456
|
if (fullValue == null) continue // record deleted concurrently
|
|
460
457
|
delete fullValue.uid
|
|
461
458
|
delete fullValue.__deleted__
|
|
462
459
|
try {
|
|
463
|
-
await app.service(modelName).updateWithMeta(elt.uid, fullValue,
|
|
460
|
+
await app.service(modelName).updateWithMeta(elt.uid, fullValue, elt.updated_at)
|
|
464
461
|
} catch(err) {
|
|
465
462
|
console.log("*** err sync user updateDatabase", err)
|
|
466
463
|
// Leave client's local version intact; it will be retried on the next sync.
|