diff --git a/src/App.vue b/src/App.vue
index 1e20e1c..7602452 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -6,7 +6,6 @@
/>
-
diff --git a/src/components/TrainsView/TrainModal.vue b/src/components/TrainsView/TrainModal.vue
deleted file mode 100644
index c2e0f71..0000000
--- a/src/components/TrainsView/TrainModal.vue
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/mixins/modalTrainMixin.ts b/src/mixins/modalTrainMixin.ts
deleted file mode 100644
index 390fdea..0000000
--- a/src/mixins/modalTrainMixin.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { defineComponent } from 'vue';
-import { useMainStore } from '../store/mainStore';
-import { useTooltipStore } from '../store/tooltipStore';
-import { Train } from '../typings/common';
-
-export default defineComponent({
- data() {
- return {
- store: useMainStore(),
- tooltipStore: useTooltipStore()
- };
- },
-
- methods: {
- selectModalTrain(train: Train, target?: EventTarget | null) {
- this.store.chosenModalTrainId = train.modalId;
- if (target) this.store.modalLastClickedTarget = target;
- },
-
- selectModalTrainById(modalId: string, target?: EventTarget | null) {
- this.store.chosenModalTrainId = modalId;
- if (target) this.store.modalLastClickedTarget = target;
- },
-
- closeModal() {
- this.store.chosenModalTrainId = undefined;
- this.tooltipStore.hide();
- }
- }
-});
diff --git a/src/store/mainStore.ts b/src/store/mainStore.ts
index 1434165..67d5a1c 100644
--- a/src/store/mainStore.ts
+++ b/src/store/mainStore.ts
@@ -50,15 +50,6 @@ export const useMainStore = defineStore('mainStore', {
const timetable = train.timetable;
- // const sceneryNames =
- // train.timetable?.sceneries?.map(
- // (sceneryHash) =>
- // apiStore.activeData?.activeSceneries?.find((st) => st.stationHash === sceneryHash)
- // ?.stationName ??
- // apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ??
- // sceneryHash
- // ) ?? [];
-
const trainObj = {
id: train.id,
modalId: `${train.driverName}${train.trainNo}`, // simplified id for train modal
@@ -219,46 +210,6 @@ export const useMainStore = defineStore('mainStore', {
});
});
- // train.timetableData.sceneryNames.forEach((name) => {
- // if (
- // acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
- // apiStore.activeData?.activeSceneries?.findIndex(
- // (sc) =>
- // sc.stationName === name &&
- // sc.region == train.region &&
- // Date.now() - sc.lastSeen < 1000 * 60 * 2
- // ) != -1
- // )
- // return acc;
-
- // acc.push({
- // name: name,
- // hash: '',
- // region: train.region,
- // maxUsers: 0,
- // currentUsers: 0,
- // spawns: [],
- // dispatcherName: '',
- // dispatcherRate: 0,
- // dispatcherId: -1,
- // dispatcherExp: -1,
- // dispatcherIsSupporter: false,
- // dispatcherStatus: Status.ActiveDispatcher.FREE,
- // dispatcherTimestamp: -1,
-
- // isOnline: false,
-
- // stationTrains: [],
- // scheduledTrains: [],
-
- // scheduledTrainCount: {
- // all: 0,
- // confirmed: 0,
- // unconfirmed: 0
- // }
- // });
- // });
-
return acc;
}, [] as ActiveScenery[]);
diff --git a/src/views/TrainsView.vue b/src/views/TrainsView.vue
index 7f19f2e..be19fdd 100644
--- a/src/views/TrainsView.vue
+++ b/src/views/TrainsView.vue
@@ -24,6 +24,7 @@ import { TrainFilter, trainFilters } from '../components/TrainsView/typings';
import { filteredTrainList } from '../managers/trainFilterManager';
import TrainStats from '../components/TrainsView/TrainStats.vue';
import { Train } from '../typings/common';
+import { useRoute, useRouter } from 'vue-router';
export default defineComponent({
components: {
@@ -55,6 +56,8 @@ export default defineComponent({
}),
setup() {
+ const router = useRouter();
+
const store = useMainStore();
const initTrainFilters = [...trainFilters.map((f) => ({ ...f }))];
@@ -88,6 +91,20 @@ export default defineComponent({
sT.length > 0 || sD.length > 0 || sA.id != 'routeDistance' || areFiltersActive;
});
+ // Backwards compatibility with external links leading to train modal
+ watch(
+ () => store.trainList,
+ (v) => {
+ if (v.length > 0 && router.currentRoute.value.query['trainId']) {
+ const queryTrainId = router.currentRoute.value.query['trainId'];
+ const train = store.trainList.find((t) => t.modalId == queryTrainId.toString());
+
+ if (!train) router.replace('/trains');
+ else router.replace(`/driver?trainId=${train.id}`);
+ }
+ }
+ );
+
return {
computedTrains,
searchedTrain,