mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore(profile): added periodic player info & history updates
This commit is contained in:
@@ -107,7 +107,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { computed, onActivated, onDeactivated, onMounted, reactive, ref } from 'vue';
|
||||
import { dateToLocaleString, humanizeDuration } from '../../composables/time';
|
||||
import { API } from '../../typings/api';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -138,6 +138,8 @@ const playerId = ref(-1);
|
||||
const playerJournal = ref<API.PlayerJournal.Data | null>(null);
|
||||
const journalDataStatus = ref(Status.Data.Initialized);
|
||||
|
||||
const intervalId = ref(-1);
|
||||
|
||||
const activeFilterTypes = reactive<Record<JournalEntryType, boolean>>({
|
||||
Timetable: true,
|
||||
Dispatcher: true,
|
||||
@@ -146,6 +148,12 @@ const activeFilterTypes = reactive<Record<JournalEntryType, boolean>>({
|
||||
|
||||
onMounted(() => {
|
||||
fetchPlayerJournal();
|
||||
intervalId.value = setInterval(fetchPlayerJournal, 30000);
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
clearInterval(intervalId.value);
|
||||
intervalId.value = -1;
|
||||
});
|
||||
|
||||
const combinedJournal = computed<JournalEntry[]>(() => {
|
||||
|
||||
@@ -21,12 +21,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import axios from 'axios';
|
||||
|
||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { onBeforeRouteUpdate, useRoute } from 'vue-router';
|
||||
import { onActivated, onDeactivated, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useApiStore } from '../store/apiStore';
|
||||
import { API, Td2API } from '../typings/api';
|
||||
import { API } from '../typings/api';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Status } from '../typings/common';
|
||||
|
||||
@@ -46,8 +44,17 @@ const playerName = ref('');
|
||||
const playerInfo = ref<API.PlayerInfo.Data | null>(null);
|
||||
const playerDataStatus = ref(Status.Data.Initialized);
|
||||
|
||||
const intervalId = ref(-1);
|
||||
|
||||
onActivated(() => {
|
||||
fetchPlayerData();
|
||||
|
||||
intervalId.value = setInterval(fetchPlayerData, 30000);
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
clearInterval(intervalId.value);
|
||||
intervalId.value = -1;
|
||||
});
|
||||
|
||||
async function fetchPlayerData() {
|
||||
|
||||
Reference in New Issue
Block a user