Add rowing to store

This commit is contained in:
2026-03-16 16:41:30 +00:00
parent 84e18dddfa
commit 6ff30a37f7

View File

@@ -1,6 +1,7 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { ref } from "vue"; import { ref } from "vue";
import { gql } from "@/graphql"; import { gql } from "@/graphql";
import axios from "axios";
export const useHomeDataStore = defineStore("homeData", () => { export const useHomeDataStore = defineStore("homeData", () => {
const loaded = ref(false); const loaded = ref(false);
@@ -11,22 +12,31 @@ export const useHomeDataStore = defineStore("homeData", () => {
const favorites = ref([]); const favorites = ref([]);
const activities = ref([]); const activities = ref([]);
const spotifyRecent = ref([]); const spotifyRecent = ref([]);
const rowingSessions = ref([]);
const gitFeed = ref(null);
const radioLive = ref(false);
async function fetchAll() { async function fetchAll() {
try { try {
const data = await gql(` const [data] = await Promise.all([
query HomeData { gql(`
posts { id title content createdAt updatedAt author { id username } } query HomeData {
favorites { id type name link createdAt } posts { id title content createdAt updatedAt author { id username } }
activities { id type name link createdAt } favorites { id type name link createdAt }
spotifyRecent { track { name album { name images { url } } artists { name } } playedAt } activities { id type name link createdAt }
me { id username admin } spotifyRecent { track { name album { name images { url } } artists { name } } playedAt }
} rowingSessions { id date time distance timePer500m calories }
`); me { id username admin }
}
`),
fetchGitFeed(),
fetchRadioStatus(),
]);
posts.value = data.posts; posts.value = data.posts;
favorites.value = data.favorites; favorites.value = data.favorites;
activities.value = data.activities; activities.value = data.activities;
spotifyRecent.value = data.spotifyRecent; spotifyRecent.value = data.spotifyRecent;
rowingSessions.value = data.rowingSessions;
me.value = data.me || null; me.value = data.me || null;
loaded.value = true; loaded.value = true;
} catch (err) { } catch (err) {
@@ -35,6 +45,24 @@ export const useHomeDataStore = defineStore("homeData", () => {
} }
} }
async function fetchGitFeed() {
try {
const res = await axios.get("/gitea/api/v1/users/adamf/activities/feeds?limit=1");
gitFeed.value = res.data[0] || null;
} catch {
gitFeed.value = null;
}
}
async function fetchRadioStatus() {
try {
await axios.head("/radio/stream");
radioLive.value = true;
} catch {
radioLive.value = false;
}
}
fetchAll(); fetchAll();
return { return {
@@ -45,6 +73,10 @@ export const useHomeDataStore = defineStore("homeData", () => {
favorites, favorites,
activities, activities,
spotifyRecent, spotifyRecent,
rowingSessions,
gitFeed,
radioLive,
fetchAll, fetchAll,
fetchRadioStatus,
}; };
}); });