mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
fix: asynchroniczność pobierania danych z API
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="journal-stats" v-show="!store.isOffline">
|
||||
<div class="journal-stats" v-if="!store.isOffline">
|
||||
<div class="tabs">
|
||||
<button
|
||||
v-for="tab in data.tabs"
|
||||
@@ -22,11 +22,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, KeepAlive, onActivated, onDeactivated, reactive, Ref, ref, watch } from 'vue';
|
||||
import { computed, KeepAlive, onActivated, onDeactivated, onMounted, reactive, Ref, ref, watch } from 'vue';
|
||||
import { useStore } from '../../store/store';
|
||||
import JournalDailyStats from './DailyStats.vue';
|
||||
import JournalDriverStats from './JournalDriverStats.vue';
|
||||
import StorageManager from '../../scripts/managers/storageManager';
|
||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||
|
||||
// Types
|
||||
type TStatTab = 'daily' | 'driver';
|
||||
@@ -60,17 +61,26 @@ function onTabButtonClick(tab: TStatTab) {
|
||||
if (tab == 'daily') {
|
||||
lastDailyStatsOpen.value = areStatsOpen.value;
|
||||
StorageManager.setBooleanValue('dailyStatsOpen', areStatsOpen.value);
|
||||
|
||||
if (areStatsOpen.value) dailyStatsComp.value?.startFetchingDailyStats();
|
||||
}
|
||||
|
||||
store.currentStatsTab = tab;
|
||||
lastClickedTab.value = tab;
|
||||
}
|
||||
|
||||
onActivated(() => {
|
||||
dailyStatsComp.value?.startFetchingDailyStats();
|
||||
|
||||
if (StorageManager.getBooleanValue('dailyStatsOpen')) areStatsOpen.value = true;
|
||||
});
|
||||
onMounted(() => {
|
||||
if (StorageManager.getBooleanValue('dailyStatsOpen')) {
|
||||
dailyStatsComp.value?.startFetchingDailyStats();
|
||||
areStatsOpen.value = true;
|
||||
}
|
||||
}),
|
||||
onActivated(async () => {
|
||||
if (StorageManager.getBooleanValue('dailyStatsOpen')) {
|
||||
dailyStatsComp.value?.startFetchingDailyStats();
|
||||
areStatsOpen.value = true;
|
||||
}
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
dailyStatsComp.value?.stopFetchingDailyStats();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
optionsType="timetables"
|
||||
/>
|
||||
|
||||
<JournalStats />
|
||||
<JournalStats v-if="dataStatus == DataStatus.Loaded" />
|
||||
|
||||
<div class="list_wrapper" @scroll="handleScroll">
|
||||
<transition name="status-anim" mode="out-in">
|
||||
@@ -165,8 +165,6 @@ export default defineComponent({
|
||||
beforeRouteUpdate(to, _) {
|
||||
this.handleQueries(to.query);
|
||||
this.fetchHistoryData();
|
||||
|
||||
console.log('test');
|
||||
},
|
||||
|
||||
activated() {
|
||||
|
||||
Reference in New Issue
Block a user