From 8fed9568202138ab108d90e29ce0a9bbd4ce2a21 Mon Sep 17 00:00:00 2001 From: Spythere Date: Tue, 3 May 2022 21:24:59 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20niepoprawne=20wy=C5=9Bwietlanie=20status?= =?UTF-8?q?=C3=B3w=20dy=C5=BCurnych?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/utils/storeUtils.ts | 4 ++-- src/store/index.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scripts/utils/storeUtils.ts b/src/scripts/utils/storeUtils.ts index 7ecea3c..8c9182b 100644 --- a/src/scripts/utils/storeUtils.ts +++ b/src/scripts/utils/storeUtils.ts @@ -6,7 +6,7 @@ export const getLocoURL = (locoType: string): string => (`https://rj.td2.info.pl export const getStatusID = (stationStatus: any): string => { if (!stationStatus) return "unknown"; - if (stationStatus == -1) return "unavailable"; + if (stationStatus == -1) return "not-signed"; const statusCode = stationStatus[2]; const statusTimestamp = stationStatus[3]; @@ -31,7 +31,7 @@ export const getStatusID = (stationStatus: any): string => { break; } - return "not-signed"; + return "unavailable"; }; export const getStatusTimestamp = (stationStatus: any): number => { diff --git a/src/store/index.ts b/src/store/index.ts index a82a88e..e205e05 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -166,9 +166,11 @@ export const store = createStore({ const prevDispatcherStatus = this.state.lastDispatcherStatuses.find(dispatcher => dispatcher.hash === stationAPI.stationHash); const stationStatus = data.dispatchers?.find((status: string[]) => status[0] == stationAPI.stationHash && status[1] == this.state.region.id) || -1; + + const statusTimestamp = prevDispatcherStatus && !data.dispatchers ? prevDispatcherStatus.statusTimestamp : getStatusTimestamp(stationStatus); + const statusID = prevDispatcherStatus && !data.dispatchers ? prevDispatcherStatus.statusID : getStatusID(stationStatus); - const statusTimestamp = getStatusTimestamp(stationStatus == -1 && prevDispatcherStatus ? prevDispatcherStatus.statusTimestamp : stationStatus); - const statusID = getStatusID(stationStatus == -1 && prevDispatcherStatus ? prevDispatcherStatus.statusID : stationStatus); + console.log(stationName, prevDispatcherStatus); prevDispatcherStatuses.push({ hash: stationAPI.stationHash,