From e2a09bca2d7a0c85ca8a427e31a616ba44607d5b Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 10 Sep 2020 23:05:52 +0200 Subject: [PATCH] =?UTF-8?q?Poprawki=20w=20dzia=C5=82aniu=20=C5=82adowania?= =?UTF-8?q?=20poci=C4=85g=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/StationsView/StationCard.vue | 16 +++++++++++----- src/components/StationsView/StationTable.vue | 1 - src/store/store.ts | 18 +++++++++--------- src/views/StationsView.vue | 2 -- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/StationsView/StationCard.vue b/src/components/StationsView/StationCard.vue index 60885a0..559d074 100644 --- a/src/components/StationsView/StationCard.vue +++ b/src/components/StationsView/StationCard.vue @@ -124,9 +124,9 @@
({ + ...stationTrain, + hasTimetable: this.trains.find(train => train.timetableData && train.trainNo === stationTrain.trainNo) + })) + } + get computedScheduledTrains() { + console.log(this.stationInfo.stationName, "test"); + return this.stationInfo.scheduledTrains.sort((a, b) => { if (a.arrivalTime > b.arrivalTime) return 1; else if ((a.arrivalTime < b.arrivalTime)) return -1; return a.departureTime > b.departureTime ? 1 : -1; }) - } - hasTimetable(trainNo: number) { - return this.trains.find(train => train.timetableData && train.trainNo === trainNo); } timestampToTime(timestamp: number) { diff --git a/src/components/StationsView/StationTable.vue b/src/components/StationsView/StationTable.vue index 2b88da1..aa4de67 100644 --- a/src/components/StationsView/StationTable.vue +++ b/src/components/StationsView/StationTable.vue @@ -145,7 +145,6 @@ import Vue from "vue"; import { Component, Prop } from "vue-property-decorator"; import Station from "@/scripts/interfaces/Station"; -import Train from "@/scripts/interfaces/Train"; import styleMixin from "@/mixins/styleMixin"; diff --git a/src/store/store.ts b/src/store/store.ts index a37c30a..cdf3012 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -97,7 +97,7 @@ export default class Store extends VuexModule { this.context.commit('setJSONData'); this.context.dispatch('fetchOnlineData'); - setInterval(() => this.context.dispatch('fetchOnlineData'), 20000); + setInterval(() => this.context.dispatch('fetchOnlineData'), 5000); } @Action({ commit: 'updateTimetableData' }) @@ -304,16 +304,14 @@ export default class Store extends VuexModule { @Mutation private updateOnlineTrains(updatedTrainList) { - this.trainList = - this.trainList.length == 0 - ? updatedTrainList - : this.trainList.reduce((acc, train) => { - const onlineTrainData = updatedTrainList.find(updatedTrain => train.trainNo === updatedTrain.trainNo); + this.trainList = updatedTrainList.reduce((acc, updatedTrain) => { + const trainData = this.trainList.find(train => train.trainNo === updatedTrain.trainNo); - if (onlineTrainData) acc.push({ ...train, ...onlineTrainData }); + if (trainData) acc.push({ ...updatedTrain, ...trainData }); + else acc.push({ ...updatedTrain }); - return acc; - }, [] as Train[]); + return acc; + }, [] as Train[]); this.trainCount = this.trainList.filter(train => train.online).length; this.dataConnectionStatus = Status.Loaded; @@ -347,6 +345,8 @@ export default class Store extends VuexModule { return acc; }, []); + // console.log('gituwa'); + return { ...station, scheduledTrains }; }); diff --git a/src/views/StationsView.vue b/src/views/StationsView.vue index 95ac079..7492821 100644 --- a/src/views/StationsView.vue +++ b/src/views/StationsView.vue @@ -124,8 +124,6 @@ export default class StationsView extends Vue { const dir: number = this.sorterActive.dir; // const scheduledTrainList = this.scheduledTrains; - - return this.stationList .filter((station) => { if (!station.reqLevel || station.reqLevel == "-1") return true;