@recordtimelabel/core 0.1.5 → 0.1.7
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/index.js +19 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const REQUIRED_FOLDERS = [
|
|
|
5
5
|
{ id: DEFAULT_FOLDER_ID, name: 'Uncategorized' }
|
|
6
6
|
];
|
|
7
7
|
|
|
8
|
-
export const RECORD_TIMELABEL_CORE_VERSION = '0.1.
|
|
8
|
+
export const RECORD_TIMELABEL_CORE_VERSION = '0.1.6';
|
|
9
9
|
|
|
10
10
|
export const OPERATION_TYPES = Object.freeze({
|
|
11
11
|
RECORD_CREATE: 'record.create',
|
|
@@ -562,6 +562,10 @@ const buildOperationSyncMeta = (previousSyncMeta = {}, operation = {}, payload =
|
|
|
562
562
|
...(previousSyncMeta?.lastOrderOperationIdByType || {}),
|
|
563
563
|
[operation.type]: operation.id || null
|
|
564
564
|
};
|
|
565
|
+
nextSyncMeta.lastOrderClientIdByType = {
|
|
566
|
+
...(previousSyncMeta?.lastOrderClientIdByType || {}),
|
|
567
|
+
[operation.type]: operation.clientId || previousSyncMeta?.lastClientId || null
|
|
568
|
+
};
|
|
565
569
|
}
|
|
566
570
|
|
|
567
571
|
return nextSyncMeta;
|
|
@@ -1409,6 +1413,12 @@ const getOrderOperationAtByType = (data = {}, operationType) => toFiniteTimestam
|
|
|
1409
1413
|
data?.syncMeta?.lastOrderOperationAtByType?.[operationType]
|
|
1410
1414
|
);
|
|
1411
1415
|
|
|
1416
|
+
const getOrderClientIdByType = (data = {}, operationType) => String(
|
|
1417
|
+
data?.rtlSyncMeta?.lastOrderClientIdByType?.[operationType] ||
|
|
1418
|
+
data?.syncMeta?.lastOrderClientIdByType?.[operationType] ||
|
|
1419
|
+
''
|
|
1420
|
+
);
|
|
1421
|
+
|
|
1412
1422
|
const hasOperationMarker = (data = {}, operationType, operationTypeResolver = getLastRemoteOperationType) => {
|
|
1413
1423
|
const lastOperationId = String(data?.rtlSyncMeta?.lastOperationId || '');
|
|
1414
1424
|
const lastOperationType = operationTypeResolver(data);
|
|
@@ -1444,12 +1454,17 @@ const hasRecentLocalOperation = (localData = {}, remoteData = {}, operationType)
|
|
|
1444
1454
|
};
|
|
1445
1455
|
|
|
1446
1456
|
const hasRemoteOrderOperationFromDifferentClient = (localData = {}, remoteData = {}, operationType) => {
|
|
1447
|
-
|
|
1457
|
+
const remoteOrderOperationAt = getMarkedOrderOperationAt(remoteData, operationType, {
|
|
1458
|
+
operationTypeResolver: getLastRemoteOperationType,
|
|
1459
|
+
operationAtResolver: getLastRemoteOperationAt
|
|
1460
|
+
});
|
|
1461
|
+
if (!remoteOrderOperationAt) {
|
|
1448
1462
|
return false;
|
|
1449
1463
|
}
|
|
1450
1464
|
|
|
1451
|
-
const remoteClientId = getLastClientId(remoteData);
|
|
1452
|
-
|
|
1465
|
+
const remoteClientId = getOrderClientIdByType(remoteData, operationType) || getLastClientId(remoteData);
|
|
1466
|
+
const localClientId = getLastClientId(localData);
|
|
1467
|
+
return Boolean(remoteClientId) && (!localClientId || remoteClientId !== localClientId);
|
|
1453
1468
|
};
|
|
1454
1469
|
|
|
1455
1470
|
const shouldPreferRecentLocalOrder = (localData = {}, remoteData = {}, operationType) => {
|