From: Michael Tremer Date: Fri, 18 Jul 2025 15:04:48 +0000 (+0000) Subject: frontend: Move the watchers into the build composable X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f521f5ac81e064fd25ed648796f8232ca3cf93ac;p=pbs.git frontend: Move the watchers into the build composable Signed-off-by: Michael Tremer --- diff --git a/frontend/src/components/BuildWatchers.vue b/frontend/src/components/BuildWatchers.vue index f307cc54..330023b6 100644 --- a/frontend/src/components/BuildWatchers.vue +++ b/frontend/src/components/BuildWatchers.vue @@ -2,7 +2,6 @@ import { ref, onMounted } from "vue"; // Composables - import type { User } from "@/api/users"; import { useBuild } from "@/composables/builds"; // Fetch the build UUID @@ -12,14 +11,13 @@ const loading = ref(true); const error = ref(null); - const watchers = ref(null); // Fetch the build - const { getWatchers } = useBuild(props.uuid); + const { watchers, getWatchers } = useBuild(props.uuid); onMounted(async () => { try { - watchers.value = await getWatchers(); + await getWatchers(); } catch (err) { error.value = err as Error; } finally { diff --git a/frontend/src/composables/builds.ts b/frontend/src/composables/builds.ts index 50a240b0..06064fd7 100644 --- a/frontend/src/composables/builds.ts +++ b/frontend/src/composables/builds.ts @@ -13,6 +13,9 @@ import type { User } from "@/api/users"; export function useBuild(uuid: string) { const build = ref(); + // Cache all watchers + const watchers = ref(); + // Fetch the build async function loadBuild() { build.value = await fetchBuild(uuid); @@ -25,11 +28,15 @@ export function useBuild(uuid: string) { // Fetch all watchers async function getWatchers(): Promise { - return await fetchBuildWatchers(uuid); + if (!watchers.value) + watchers.value = await fetchBuildWatchers(uuid); + + return watchers.value; } return { build, + watchers, loadBuild, getBugs, getWatchers,