From 163a4b47de48b4b299527764a8a0ffa9fc7ef002 Mon Sep 17 00:00:00 2001 From: Spythere Date: Tue, 24 May 2022 18:58:30 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20status=C3=B3w=20scenerii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/store/index.ts b/src/store/index.ts index fd88748..8aeb748 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -158,6 +158,7 @@ export const store = createStore({ const onlineStationNames: string[] = []; const prevDispatcherStatuses: State['lastDispatcherStatuses'] = []; + console.log(data.dispatchers); data.stations?.forEach((stationAPI) => { if (stationAPI.region !== this.state.region.id || !stationAPI.isOnline) return; @@ -167,7 +168,7 @@ export const store = createStore({ const station = this.state.stationList.find(s => s.name == stationAPI.stationName); 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 stationStatus = !data.dispatchers ? undefined : 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);