]> git.ipfire.org Git - pbs.git/commitdiff
frontend: Move the watchers into the build composable
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Jul 2025 15:04:48 +0000 (15:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Jul 2025 15:04:48 +0000 (15:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
frontend/src/components/BuildWatchers.vue
frontend/src/composables/builds.ts

index f307cc545d8649c5630291c9fd0ea8b4c14a1df7..330023b68531044c9e6b8d362ee6a931c1db8f58 100644 (file)
@@ -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
 
        const loading = ref(true);
        const error = ref<Error | null>(null);
-       const watchers = ref<User[] | null>(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 {
index 50a240b0537147410a6eba8d447beb698c814be1..06064fd722f22ea780a359d7aaff249796895285 100644 (file)
@@ -13,6 +13,9 @@ import type { User } from "@/api/users";
 export function useBuild(uuid: string) {
        const build = ref<Build>();
 
+       // Cache all watchers
+       const watchers = ref<User[]>();
+
        // 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<User[]> {
-               return await fetchBuildWatchers(uuid);
+               if (!watchers.value)
+                       watchers.value = await fetchBuildWatchers(uuid);
+
+               return watchers.value;
        }
 
        return {
                build,
+               watchers,
                loadBuild,
                getBugs,
                getWatchers,