Give the job tracker stores and fix the admin route guard
createCrudStore captures the places store's pattern and now backs places, job applications and job references. JobApplications.vue no longer calls gql() itself and is split into the applications table, the references table and the add form, with the status vocabulary in jobStatus.js. api.js is a thin REST client that turns failures into an ApiError carrying the backend's message; the admin views and Listening.vue use it in place of raw axios and fetch. The router guard waited on the home query's loaded flag, which is never set when that query fails, so /admin and /cv/jobs could hang. It now awaits a standalone me query owned by the auth store, and homeData gains a settled flag for widgets that only need to know the fetch finished. The Vite proxy targets are configurable through VITE_PROXY_*, and build:js runs the Vite build without wasm-pack. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -27,12 +27,14 @@ const CreateRowing = defineAsyncComponent(
|
||||
);
|
||||
|
||||
const store = useHomeDataStore();
|
||||
const { loaded, error, rowingSessions } = storeToRefs(store);
|
||||
const { settled, error, rowingSessions } = storeToRefs(store);
|
||||
const showCreate = ref(false);
|
||||
|
||||
// slice() first: reverse() mutates in place and would reorder the store's array.
|
||||
const rows = computed(() => rowingSessions.value.slice().reverse());
|
||||
const loading = computed(() => !loaded.value);
|
||||
// `settled`, not `loaded`: a home query that fails never sets `loaded`, and the
|
||||
// error branch below would be unreachable behind a permanent spinner.
|
||||
const loading = computed(() => !settled.value);
|
||||
|
||||
const metric = ref("distance");
|
||||
const hovered = ref(null);
|
||||
|
||||
@@ -10,6 +10,7 @@ import { computed, onMounted } from "vue";
|
||||
import { useSongsStore } from "@/stores/songs";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useRotation } from "@/js/useRotation";
|
||||
import { api } from "@/api";
|
||||
|
||||
const ROTATE_MS = 5000;
|
||||
const REFRESH_MS = 120000;
|
||||
@@ -38,9 +39,7 @@ const showReconnect = computed(
|
||||
// stays as it was.
|
||||
async function reconnect() {
|
||||
try {
|
||||
const res = await fetch("/api/spotify/auth");
|
||||
if (!res.ok) return;
|
||||
const { url } = await res.json();
|
||||
const { url } = await api.get("/spotify/auth");
|
||||
window.location.href = url;
|
||||
} catch (err) {
|
||||
console.error("Cannot start Spotify re-authentication", err);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Steam widget on /stp: online status plus a rotation through recent games
|
||||
* (5s rotation, 5-minute re-poll, both from useRotation()). `loaded` comes from
|
||||
* (5s rotation, 5-minute re-poll, both from useRotation()). `settled` comes from
|
||||
* homeData so the widget can tell "not fetched yet" from "fetched, nothing to
|
||||
* show".
|
||||
* show" — and, unlike `loaded`, it also turns true when the fetch fails, so the
|
||||
* widget cannot sit on "Loading..." forever.
|
||||
*/
|
||||
import { computed } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -18,7 +19,7 @@ const REFRESH_MS = 5 * 60 * 1000;
|
||||
const steamStore = useSteamStore();
|
||||
const { steamStatus } = storeToRefs(steamStore);
|
||||
const homeData = useHomeDataStore();
|
||||
const { loaded } = storeToRefs(homeData);
|
||||
const { settled } = storeToRefs(homeData);
|
||||
|
||||
const { idx, next: nextGame } = useRotation(
|
||||
() => steamStatus.value.recentGames,
|
||||
@@ -47,7 +48,7 @@ function formatHours(minutes) {
|
||||
</span>
|
||||
</Header>
|
||||
|
||||
<div v-if="!loaded" class="p-2 text-sm">Loading...</div>
|
||||
<div v-if="!settled" class="p-2 text-sm">Loading...</div>
|
||||
|
||||
<div v-else-if="game" class="game-container">
|
||||
<Transition name="fade">
|
||||
|
||||
Reference in New Issue
Block a user