mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cfe073bab | |||
| e3b72c81ea | |||
| 5552995564 | |||
| 623d5dd2ce | |||
| 6992b998a8 | |||
| 669975c68e | |||
| 084823de44 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stacjownik",
|
"name": "stacjownik",
|
||||||
"version": "1.22.1",
|
"version": "1.22.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
window.addEventListener('focus', () => {
|
||||||
|
if (Date.now() - this.apiStore.lastFetchData.getTime() < 15000) return;
|
||||||
|
|
||||||
|
this.apiStore.fetchActiveData();
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => this.store.blockScroll,
|
() => this.store.blockScroll,
|
||||||
(value) => {
|
(value) => {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export default defineComponent({
|
|||||||
regionList() {
|
regionList() {
|
||||||
return regionsJSON.map((region) => {
|
return regionsJSON.map((region) => {
|
||||||
const regionStationCount = this.store.activeSceneryList.filter(
|
const regionStationCount = this.store.activeSceneryList.filter(
|
||||||
(scenery) => scenery.region == region.id
|
(scenery) => scenery.region == region.id && scenery.dispatcherId != -1
|
||||||
).length;
|
).length;
|
||||||
|
|
||||||
const regionTrainCount =
|
const regionTrainCount =
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
class="timetable-item"
|
class="timetable-item"
|
||||||
v-else
|
v-else
|
||||||
v-for="scheduledTrain in computedScheduledTrains"
|
v-for="scheduledTrain in computedScheduledTrains"
|
||||||
:key="scheduledTrain.trainId"
|
:key="scheduledTrain.trainId + scheduledTrain.stopInfo.arrivalTimestamp"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@click.prevent.stop="selectModalTrain(scheduledTrain.trainId, $event.currentTarget)"
|
@click.prevent.stop="selectModalTrain(scheduledTrain.trainId, $event.currentTarget)"
|
||||||
@keydown.enter.prevent="selectModalTrain(scheduledTrain.trainId, $event.currentTarget)"
|
@keydown.enter.prevent="selectModalTrain(scheduledTrain.trainId, $event.currentTarget)"
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export const useApiStore = defineStore('apiStore', {
|
|||||||
donatorsData: [] as API.Donators.Response,
|
donatorsData: [] as API.Donators.Response,
|
||||||
sceneryData: [] as StationJSONData[],
|
sceneryData: [] as StationJSONData[],
|
||||||
|
|
||||||
|
lastFetchData: new Date(),
|
||||||
|
|
||||||
client: undefined as AxiosInstance | undefined,
|
client: undefined as AxiosInstance | undefined,
|
||||||
|
|
||||||
activeDataScheduler: undefined as number | undefined
|
activeDataScheduler: undefined as number | undefined
|
||||||
@@ -64,20 +66,19 @@ export const useApiStore = defineStore('apiStore', {
|
|||||||
async setupActiveDataFetcher() {
|
async setupActiveDataFetcher() {
|
||||||
if (this.activeDataScheduler) return;
|
if (this.activeDataScheduler) return;
|
||||||
|
|
||||||
this.dataStatuses.connection = Status.Data.Loading;
|
|
||||||
|
|
||||||
this.activeDataScheduler = window.setInterval(() => {
|
this.activeDataScheduler = window.setInterval(() => {
|
||||||
if (UPDATE_SECONDS.includes(new Date().getSeconds())) {
|
this.fetchActiveData();
|
||||||
this.fetchActiveData();
|
}, 25000);
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchActiveData() {
|
async fetchActiveData() {
|
||||||
|
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
|
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
|
||||||
|
|
||||||
this.activeData = response.data;
|
this.activeData = response.data;
|
||||||
|
this.lastFetchData = new Date();
|
||||||
this.dataStatuses.connection = Status.Data.Loaded;
|
this.dataStatuses.connection = Status.Data.Loaded;
|
||||||
|
|
||||||
console.log('Fetching active data at ' + new Date().toLocaleTimeString('pl-PL'));
|
console.log('Fetching active data at ' + new Date().toLocaleTimeString('pl-PL'));
|
||||||
|
|||||||
@@ -107,7 +107,10 @@ export const useMainStore = defineStore('store', {
|
|||||||
if (
|
if (
|
||||||
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
acc.findIndex((v) => v.name == name && v.region == train.region) != -1 ||
|
||||||
apiStore.activeData?.activeSceneries?.findIndex(
|
apiStore.activeData?.activeSceneries?.findIndex(
|
||||||
(sc) => sc.stationName === name && sc.region == train.region
|
(sc) =>
|
||||||
|
sc.stationName === name &&
|
||||||
|
sc.region == train.region &&
|
||||||
|
Date.now() - sc.lastSeen < 1000 * 60 * 2
|
||||||
) != -1
|
) != -1
|
||||||
)
|
)
|
||||||
return acc;
|
return acc;
|
||||||
|
|||||||
Reference in New Issue
Block a user