mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-11-16 00:20:37 +08:00
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.
31 lines
887 B
TypeScript
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];
|
|
}
|