mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
fix(app): improved data fetching scheduler
This commit is contained in:
+16
-5
@@ -70,7 +70,9 @@ export default defineComponent({
|
||||
|
||||
currentLang: 'pl',
|
||||
releaseURL: '',
|
||||
isOnProductionHost: location.hostname == 'stacjownik-td2.web.app'
|
||||
isOnProductionHost: location.hostname == 'stacjownik-td2.web.app',
|
||||
|
||||
nextUpdateTime: 0
|
||||
}),
|
||||
|
||||
created() {
|
||||
@@ -78,11 +80,11 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
window.addEventListener('focus', () => {
|
||||
if (Date.now() - this.apiStore.lastFetchData.getTime() < 15000) return;
|
||||
// window.addEventListener('focus', () => {
|
||||
// if (Date.now() - this.apiStore.lastFetchData.getTime() < 15000) return;
|
||||
|
||||
this.apiStore.fetchActiveData();
|
||||
});
|
||||
// this.apiStore.fetchActiveData();
|
||||
// });
|
||||
|
||||
window.addEventListener('mousemove', (e: MouseEvent) => this.handlePopUpEvents(e));
|
||||
},
|
||||
@@ -95,10 +97,19 @@ export default defineComponent({
|
||||
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);
|
||||
},
|
||||
|
||||
checkAppVersion() {
|
||||
if (import.meta.env.DEV) {
|
||||
this.store.isNewUpdate = true;
|
||||
|
||||
Reference in New Issue
Block a user