mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-02 21:18:12 +00:00
chore: changed to new order's version in local storage
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
:selected="order.id == store.chosenLocalOrderId"
|
||||
:key="order.id"
|
||||
>
|
||||
<b class="text--accent">#{{ order.id.split('-')[1] }} </b>
|
||||
<b class="text--accent">#{{ order.id.split('-')[2] }} </b>
|
||||
<b>
|
||||
{{
|
||||
t('order-list.order-title', {
|
||||
@@ -80,7 +80,7 @@ function removeOrder(orderId: string) {
|
||||
const orderIndex = storageOrderList.findIndex((o) => o.id == orderId);
|
||||
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) {
|
||||
@@ -116,10 +116,8 @@ onActivated(() => {
|
||||
const localStorage = window.localStorage;
|
||||
const orderList = [];
|
||||
|
||||
let deprecatedOrders = 0;
|
||||
|
||||
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]);
|
||||
if (!orderObj) continue;
|
||||
@@ -132,9 +130,6 @@ onActivated(() => {
|
||||
orderList.push(orderObj);
|
||||
}
|
||||
|
||||
if (deprecatedOrders != 0) {
|
||||
}
|
||||
|
||||
storageOrderList.length = 0;
|
||||
storageOrderList.push(...orderList);
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<LucidePencil />
|
||||
{{ $t('order-message.button-update') }}
|
||||
<span class="text--accent">
|
||||
{{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[1]}` }}
|
||||
{{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[2]}` }}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
@@ -317,11 +317,11 @@ function saveOrder() {
|
||||
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) {
|
||||
try {
|
||||
@@ -339,10 +339,10 @@ function saveOrder() {
|
||||
}
|
||||
|
||||
const nextOrderCount = localOrderCount + 1;
|
||||
const nextOrderId = `order-${nextOrderCount}`;
|
||||
const nextOrderId = `order-v3-${nextOrderCount}`;
|
||||
orderDataToSave['id'] = nextOrderId;
|
||||
|
||||
StorageManager.setNumericValue('orderCount', nextOrderCount);
|
||||
StorageManager.setNumericValue('orderCountV3', nextOrderCount);
|
||||
StorageManager.setValue(nextOrderId, JSON.stringify(orderDataToSave));
|
||||
|
||||
store.chosenLocalOrderId = nextOrderId;
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@
|
||||
},
|
||||
"order-list": {
|
||||
"title": "Saved train orders",
|
||||
"order-title": "Train order for train no. {trainNo}",
|
||||
"order-title": "Train order for no. {trainNo}",
|
||||
"order-subtitle": "Selected instructions: {0}",
|
||||
"no-saved-orders": "No saved orders!",
|
||||
"order-added": "Added:",
|
||||
|
||||
Reference in New Issue
Block a user