diff --git a/index.html b/index.html
index ad84025..fa01a2b 100644
--- a/index.html
+++ b/index.html
@@ -19,7 +19,6 @@
-
diff --git a/src/App.vue b/src/App.vue
index 9560b62..a795bfa 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -81,9 +81,7 @@ export default defineComponent({
isUpdateCardOpen: false,
currentLang: 'pl',
- isOnProductionHost: location.hostname == 'stacjownik-td2.web.app',
-
- nextUpdateTime: 0
+ isOnProductionHost: location.hostname == 'stacjownik-td2.web.app'
}),
created() {
@@ -96,22 +94,13 @@ export default defineComponent({
methods: {
init() {
+ if (!this.isOnProductionHost) document.title = 'Stacjownik Dev';
+
this.loadLang();
this.setupOfflineHandling();
this.checkAppVersion();
this.apiStore.setupAPIData();
- window.requestAnimationFrame(this.update);
-
- if (!this.isOnProductionHost) document.title = 'Stacjownik Dev';
- },
-
- update(t: number) {
- if (t >= this.nextUpdateTime) {
- this.apiStore.fetchActiveData();
- this.nextUpdateTime = t + 20000;
- }
- window.requestAnimationFrame(this.update);
},
async checkAppVersion() {
@@ -131,7 +120,7 @@ export default defineComponent({
};
this.isUpdateCardOpen =
- (storageVersion != '' && storageVersion != version) ||
+ (storageVersion != '' && storageVersion != version && this.isOnProductionHost) ||
import.meta.env.VITE_UPDATE_TEST === 'test';
} catch (error) {
console.error(`Wystąpił błąd podczas pobierania danych z API GitHuba: ${error}`);
@@ -158,6 +147,7 @@ export default defineComponent({
handleOnlineMode() {
this.store.isOffline = false;
+ this.apiStore.dataStatuses.connection = Status.Data.Loading;
this.apiStore.connectToAPI();
},
diff --git a/src/store/apiStore.ts b/src/store/apiStore.ts
index 4e66840..a8ddd86 100644
--- a/src/store/apiStore.ts
+++ b/src/store/apiStore.ts
@@ -18,7 +18,7 @@ export const useApiStore = defineStore('apiStore', {
donatorsData: [] as API.Donators.Response,
sceneryData: [] as StationJSONData[],
- lastFetchData: new Date(),
+ nextUpdateTime: 0,
client: undefined as AxiosInstance | undefined,
@@ -51,27 +51,33 @@ export const useApiStore = defineStore('apiStore', {
// Static data
this.fetchDonatorsData();
this.fetchStationsGeneralInfo();
-
- // Ponowne pobieranie danych po ServiceWorkerze
- setTimeout(() => {
- this.fetchStationsGeneralInfo();
- }, Math.floor(Math.random() * 500) + 1000);
-
this.fetchVehiclesInfo();
+
+ window.requestAnimationFrame(this.updateTick);
+ },
+
+ updateTick(t: number) {
+ if (this.dataStatuses.connection == Status.Data.Offline) return;
+
+ if (t >= this.nextUpdateTime) {
+ this.fetchActiveData();
+ this.nextUpdateTime = t + 20000;
+ }
+
+ window.requestAnimationFrame(this.updateTick);
},
async fetchActiveData() {
- if (import.meta.env.VITE_API_ACTIVE_DATA_MODE == 'mocking') {
- import('../../tests/data/getActiveData.json').then((data) => {
- console.warn('activeData: mocking mode');
- this.activeData = data.default as API.ActiveData.Response;
- this.lastFetchData = new Date();
+ // if (import.meta.env.VITE_API_ACTIVE_DATA_MODE == 'mocking') {
+ // import('../../tests/data/getActiveData.json').then((data) => {
+ // console.warn('activeData: mocking mode');
+ // this.activeData = data.default as API.ActiveData.Response;
- this.dataStatuses.connection = Status.Data.Loaded;
- });
+ // this.dataStatuses.connection = Status.Data.Loaded;
+ // });
- return;
- }
+ // return;
+ // }
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
@@ -79,7 +85,6 @@ export const useApiStore = defineStore('apiStore', {
const response = await this.client!.get('api/getActiveData');
this.activeData = response.data;
- this.lastFetchData = new Date();
this.dataStatuses.connection = Status.Data.Loaded;
} catch (error) {
this.dataStatuses.connection = Status.Data.Error;