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