diff --git a/src/scripts/interfaces/Train.ts b/src/scripts/interfaces/Train.ts index 6308bd3..acf0c25 100644 --- a/src/scripts/interfaces/Train.ts +++ b/src/scripts/interfaces/Train.ts @@ -15,6 +15,7 @@ export default interface Train { locoURL: string; locoType: string; online: boolean; + region: string; cars: string[]; diff --git a/src/store/index.ts b/src/store/index.ts index d7ba59f..909c085 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -162,6 +162,7 @@ export const store = createStore({ const stationTrains = onlineTrainsData.success ? onlineTrainsData.message .filter(train => train.region === this.state.region.id && train.isOnline && train.station.stationName === station.stationName) .map(train => ({ driverName: train.driverName, trainNo: train.trainNo })) : []; + acc.push({ name: station.stationName, @@ -204,10 +205,10 @@ export const store = createStore({ connectedTrack: train.dataSceneryConnection, locoType, locoURL: getLocoURL(locoType), - cars: train.dataCon.split(";").filter((train, i) => i > 0) || [] + cars: train.dataCon.split(";").filter((train, i) => i > 0) || [], }; }) - ) : []; + ) : []; // Pass reduced lists to mutations commit(MUTATIONS.UPDATE_STATIONS, updatedStationList); @@ -463,9 +464,10 @@ export const store = createStore({ else acc.push({ ...updatedTrain }); return acc; - }, [] as Train[]); + }, [] as Train[]); - state.trainCount = state.trainList.filter(train => train.online).length; + state.trainCount = state.trainList.length; + state.dataConnectionStatus = DataStatus.Loaded; }, @@ -573,7 +575,7 @@ export const store = createStore({ const timetable = timetableList.find(tt => tt.data && tt.trainNo === train.trainNo && tt.data.driverId === train.driverId); const allTimetables = timetableList.filter(tt => tt.data && tt.data.driverId === train.driverId && tt.trainNo !== train.trainNo); - if (!timetable || !timetable.data) return acc; + // if (!timetable || !timetable.data) return acc; if (allTimetables.length > 0) return acc; @@ -582,7 +584,7 @@ export const store = createStore({ .find(station => station.name === train.currentStationName) ?.onlineInfo?.scheduledTrains?.find(stationTrain => stationTrain.trainNo === train.trainNo); - acc.push({ ...train, timetableData: timetable.data, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" }); + acc.push({ ...train, timetableData: timetable?.data, stopStatus: trainStopData?.stopStatus || "", stopLabel: trainStopData?.stopLabel || "" }); return acc; }, [] as Train[]); diff --git a/src/views/TrainsView.vue b/src/views/TrainsView.vue index 560b881..c30a7de 100644 --- a/src/views/TrainsView.vue +++ b/src/views/TrainsView.vue @@ -48,6 +48,7 @@ const filteredTrainList = ( searchedDriver: string, sorterActive: { id: string; dir: number } ) => { + return trainList .filter( (train) => @@ -113,12 +114,12 @@ export default defineComponent({ trainStatsOpen: false, }), - setup(props) { + setup() { const store = useStore(); const trainList: ComputedRef = computed(() => store.getters[GETTERS.trainList]); - const timetableDataStatus: ComputedRef = computed(() => store.getters[GETTERS.timetableDataStatus]); + // const timetableDataStatus: ComputedRef = computed(() => store.getters[GETTERS.timetableDataStatus]); const sorterActive = ref({ id: 'distance', dir: -1 }); const searchedDriver = ref('');