All files / apps/developer-portal/layers/health/app/composables useIssueList.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25      1x   6x   6x 6x   6x 6x 8x     6x 6x 1x 1x 1x     6x    
import { filterIssues, sortIssues } from "#layers/github/app/utils/issues.ts";
 
/** The live issue read, filtered and newest first, with a manual re-read. */
export const useIssueList = () => {
    // Not awaited: `await` resolves to the plain `useFetch` state and would drop `reload` with it.
    const { data: issues, reload } = useIssues();
 
    const label = ref("all");
    const search = ref("");
 
    const all = computed(() => issues.value.issues);
    const visible = computed(() =>
        sortIssues(filterIssues(all.value, { label: label.value, search: search.value })),
    );
 
    const reloading = ref(false);
    const refresh = async (): Promise<void> => {
        reloading.value = true;
        await reload();
        reloading.value = false;
    };
 
    return { issues, label, search, all, visible, reloading, refresh };
};