Files
radicle-desktop/src/lib/issueCounts.svelte.ts
T
Sebastian Martinez 499a0983ea Add rebuild cache functionality to issue and patch listing
In case of an outdated cobs cache we display a banner on top of the
patch or issue listing, to allow users to rebuild the cobs cache of a
repo similar to running `rad patch cache`
After rebuilding we fetch the issues or patches from the start.

Small caveat with patches:
The banner can only be shown after a user fetched all patches from the
backend, so we are sure we tried to fetch all of them.
2025-06-11 18:24:27 +02:00

31 lines
887 B
TypeScript

import type { IssueStatus } from "@app/views/repo/router";
import type { ProjectPayload } from "@bindings/repo/ProjectPayload";
export const issueCounts = $state<
Record<IssueStatus, { sidebar: number | null; total: number | null }>
>({
all: { sidebar: null, total: null },
open: { sidebar: null, total: null },
closed: { sidebar: null, total: null },
});
export function issueCountMismatch(status: IssueStatus) {
return issueCounts[status].total !== issueCounts[status].sidebar;
}
export function resetIssueCounts() {
Object.values(issueCounts).forEach(count => {
count.sidebar = null;
count.total = null;
});
}
export function updateIssueCounts(
itemCount: number,
sidebarCount: ProjectPayload["meta"]["issues"] & { all: number },
status: IssueStatus,
) {
issueCounts[status].total = itemCount;
issueCounts[status].sidebar = sidebarCount[status];
}