chore: changed to new order's version in local storage

This commit is contained in:
2025-10-11 00:39:29 +02:00
parent 201c49845f
commit 33f59db5f3
3 changed files with 10 additions and 15 deletions
+3 -8
View File
@@ -12,7 +12,7 @@
:selected="order.id == store.chosenLocalOrderId" :selected="order.id == store.chosenLocalOrderId"
:key="order.id" :key="order.id"
> >
<b class="text--accent">#{{ order.id.split('-')[1] }}&nbsp;</b> <b class="text--accent">#{{ order.id.split('-')[2] }}&nbsp;</b>
<b> <b>
{{ {{
t('order-list.order-title', { t('order-list.order-title', {
@@ -80,7 +80,7 @@ function removeOrder(orderId: string) {
const orderIndex = storageOrderList.findIndex((o) => o.id == orderId); const orderIndex = storageOrderList.findIndex((o) => o.id == orderId);
if (orderIndex != -1) storageOrderList.splice(orderIndex, 1); if (orderIndex != -1) storageOrderList.splice(orderIndex, 1);
if (storageOrderList.length == 0) StorageManager.setNumericValue('orderCount', 0); if (storageOrderList.length == 0) StorageManager.setNumericValue('orderCountV3', 0);
} }
function selectLocalOrder(order: IStorageOrderData) { function selectLocalOrder(order: IStorageOrderData) {
@@ -116,10 +116,8 @@ onActivated(() => {
const localStorage = window.localStorage; const localStorage = window.localStorage;
const orderList = []; const orderList = [];
let deprecatedOrders = 0;
for (let key in localStorage) { for (let key in localStorage) {
if (!/^order-/g.test(key)) continue; if (!/^order-v3/g.test(key)) continue;
const orderObj: IStorageOrderData | LocalStorageOrderLegacy = JSON.parse(localStorage[key]); const orderObj: IStorageOrderData | LocalStorageOrderLegacy = JSON.parse(localStorage[key]);
if (!orderObj) continue; if (!orderObj) continue;
@@ -132,9 +130,6 @@ onActivated(() => {
orderList.push(orderObj); orderList.push(orderObj);
} }
if (deprecatedOrders != 0) {
}
storageOrderList.length = 0; storageOrderList.length = 0;
storageOrderList.push(...orderList); storageOrderList.push(...orderList);
}); });
+6 -6
View File
@@ -26,7 +26,7 @@
<LucidePencil /> <LucidePencil />
{{ $t('order-message.button-update') }} {{ $t('order-message.button-update') }}
<span class="text--accent"> <span class="text--accent">
{{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[1]}` }} {{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[2]}` }}
</span> </span>
</button> </button>
@@ -317,11 +317,11 @@ function saveOrder() {
orderData: store.orderData orderData: store.orderData
}; };
const localOrderCount = StorageManager.getNumericValue('orderCount') || 0; const localOrderCount = StorageManager.getNumericValue('orderCountV3') || 0;
if (localOrderCount == 0) StorageManager.setNumericValue('orderCount', 0); if (localOrderCount == 0) StorageManager.setNumericValue('orderCountV3', 0);
const prevLocalOrder = StorageManager.getValue(`order-${localOrderCount}`); const prevLocalOrder = StorageManager.getValue(`order-v3-${localOrderCount}`);
if (prevLocalOrder) { if (prevLocalOrder) {
try { try {
@@ -339,10 +339,10 @@ function saveOrder() {
} }
const nextOrderCount = localOrderCount + 1; const nextOrderCount = localOrderCount + 1;
const nextOrderId = `order-${nextOrderCount}`; const nextOrderId = `order-v3-${nextOrderCount}`;
orderDataToSave['id'] = nextOrderId; orderDataToSave['id'] = nextOrderId;
StorageManager.setNumericValue('orderCount', nextOrderCount); StorageManager.setNumericValue('orderCountV3', nextOrderCount);
StorageManager.setValue(nextOrderId, JSON.stringify(orderDataToSave)); StorageManager.setValue(nextOrderId, JSON.stringify(orderDataToSave));
store.chosenLocalOrderId = nextOrderId; store.chosenLocalOrderId = nextOrderId;
+1 -1
View File
@@ -55,7 +55,7 @@
}, },
"order-list": { "order-list": {
"title": "Saved train orders", "title": "Saved train orders",
"order-title": "Train order for train no. {trainNo}", "order-title": "Train order for no. {trainNo}",
"order-subtitle": "Selected instructions: {0}", "order-subtitle": "Selected instructions: {0}",
"no-saved-orders": "No saved orders!", "no-saved-orders": "No saved orders!",
"order-added": "Added:", "order-added": "Added:",