mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
fix(api): update tick awaiting for all static data to refresh before requesting active data
This commit is contained in:
@@ -7,6 +7,7 @@ import axios, { AxiosInstance } from 'axios';
|
|||||||
export const useApiStore = defineStore('apiStore', {
|
export const useApiStore = defineStore('apiStore', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
dataStatuses: {
|
dataStatuses: {
|
||||||
|
allData: Status.Data.Loading,
|
||||||
connection: Status.Data.Loading,
|
connection: Status.Data.Loading,
|
||||||
sceneries: Status.Data.Loading,
|
sceneries: Status.Data.Loading,
|
||||||
vehicles: Status.Data.Loading,
|
vehicles: Status.Data.Loading,
|
||||||
@@ -55,19 +56,19 @@ export const useApiStore = defineStore('apiStore', {
|
|||||||
window.requestAnimationFrame(this.updateTick);
|
window.requestAnimationFrame(this.updateTick);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTick(t: number) {
|
async updateTick(t: number) {
|
||||||
// Static data refresh
|
// Static data refresh
|
||||||
if (t >= this.nextDataCheckTime) {
|
if (t >= this.nextDataCheckTime) {
|
||||||
this.fetchDonatorsData();
|
await this.fetchStationsGeneralInfo();
|
||||||
this.fetchVehiclesInfo();
|
await this.fetchVehiclesInfo();
|
||||||
this.fetchStationsGeneralInfo();
|
await this.fetchDonatorsData();
|
||||||
|
|
||||||
this.nextDataCheckTime = t + 3600000;
|
this.nextDataCheckTime = t + 3600000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Active data fefresh
|
// Active data fefresh
|
||||||
if (t >= this.nextUpdateTime) {
|
if (t >= this.nextUpdateTime) {
|
||||||
this.fetchActiveData();
|
await this.fetchActiveData();
|
||||||
this.nextUpdateTime = t + 31000;
|
this.nextUpdateTime = t + 31000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user