feat: router links embeded into timetable stop names

This commit is contained in:
2024-08-18 23:45:42 +02:00
parent 6bd62f13a1
commit 80a5b56785
6 changed files with 77 additions and 25 deletions
+56 -13
View File
@@ -50,14 +50,14 @@ 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 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,
@@ -96,7 +96,7 @@ export const useMainStore = defineStore('mainStore', {
followingStops: timetable.stopList,
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
sceneries: timetable.sceneries,
sceneryNames: sceneryNames.reverse(),
// sceneryNames: sceneryNames.reverse(),
timetablePath: timetable.path.split(';').map((pathElementString) => {
const [arrival, station, departure] = pathElementString.split(',');
@@ -169,12 +169,15 @@ export const useMainStore = defineStore('mainStore', {
const offlineActiveSceneries = this.trainList.reduce((acc, train) => {
if (!train.timetableData) return acc;
train.timetableData.sceneryNames.forEach((name) => {
train.timetableData.timetablePath.forEach((p) => {
if (
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
acc.findIndex(
(v) =>
(v.name == p.stationName || v.hash == p.stationHash) && v.region == train.region
) != -1 ||
apiStore.activeData?.activeSceneries?.findIndex(
(sc) =>
sc.stationName === name &&
(sc.stationName == p.stationName || sc.stationHash == p.stationHash) &&
sc.region == train.region &&
Date.now() - sc.lastSeen < 1000 * 60 * 2
) != -1
@@ -182,7 +185,7 @@ export const useMainStore = defineStore('mainStore', {
return acc;
acc.push({
name: name,
name: p.stationName,
hash: '',
region: train.region,
maxUsers: 0,
@@ -209,6 +212,46 @@ 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[]);