mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 13:38: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"
|
:selected="order.id == store.chosenLocalOrderId"
|
||||||
:key="order.id"
|
:key="order.id"
|
||||||
>
|
>
|
||||||
<b class="text--accent">#{{ order.id.split('-')[1] }} </b>
|
<b class="text--accent">#{{ order.id.split('-')[2] }} </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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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
@@ -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:",
|
||||||
|
|||||||
Reference in New Issue
Block a user