chore: checking whether new order is the same as the last one saved

This commit is contained in:
2025-10-01 14:50:44 +02:00
parent 5fb235c9a7
commit 70d29284a5
+14 -4
View File
@@ -290,11 +290,21 @@ function saveOrder() {
if (localOrderCount == 0) StorageManager.setNumericValue('orderCount', 0); if (localOrderCount == 0) StorageManager.setNumericValue('orderCount', 0);
const prevLocalOrder = StorageManager.getValue(`order-${Number(localOrderCount)}`); const prevLocalOrder = StorageManager.getValue(`order-${localOrderCount}`);
if (prevLocalOrder && prevLocalOrder == JSON.stringify(orderDataToSave)) { if (prevLocalOrder) {
showActionMonit(t('order-message.warning-order-identical'), 'warning'); try {
return; const prevOrderObj = JSON.parse(prevLocalOrder) as IStorageOrderData;
if (JSON.stringify(prevOrderObj.orderData) == JSON.stringify(orderDataToSave.orderData)) {
showActionMonit(t('order-message.warning-order-identical'), 'warning');
return;
}
} catch (error) {
console.error(
`Ups! An error occured when trying to parse previous local order (count: ${localOrderCount})`
);
}
} }
const nextOrderCount = localOrderCount + 1; const nextOrderCount = localOrderCount + 1;