desktop: Keep the repo list and release counts in the cache

The repo list had its own TTL cache, a counter bumped by seeding and a
listener of its own, and release counts were fetched separately by the
sidebar and the releases page. Now they're queries like the rest, and
seeding invalidates the list like any other write. The head a loader
resolved is marked through `markLoading` too, so it needs no key of its
own.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:17 +01:00
parent e0fb0da7a0
commit b1c3e2c639
15 changed files with 168 additions and 206 deletions
+6 -2
View File
@@ -5,8 +5,10 @@
<script lang="ts">
import { z } from "zod";
import { repoList } from "@app/lib/cobQueries";
import { nodeRunning } from "@app/lib/events";
import { cachedListReposWithActors, invoke } from "@app/lib/invoke";
import { invoke } from "@app/lib/invoke";
import { queryClient } from "@app/lib/query";
import { repoListScope } from "@app/lib/repoListScope";
import { seedTarget } from "@app/lib/seedRepo";
import useLocalStorage from "@app/lib/useLocalStorage.svelte";
@@ -61,7 +63,9 @@
// The project list hides actor repositories, so this check uses the full
// list.
const stored = await cachedListReposWithActors(repoListScope.value);
const { repos: stored } = await queryClient.fetchQuery(
repoList(repoListScope.value),
);
const target = seedTarget(
rid,
seededNotReplicated,
+3 -2
View File
@@ -25,7 +25,7 @@
import { scrollBehavior } from "@app/lib/motion";
import type { Route } from "@app/lib/router";
import { push, routeToPath } from "@app/lib/router";
import { fetchingRepos } from "@app/lib/seedRepo";
import { createFetchingRepos } from "@app/lib/seedRepo";
import {
formatOid,
issueStatusColor,
@@ -75,8 +75,9 @@
const repoName = $derived(resolvedRepoName ?? fallback);
const fetchingRepos = createFetchingRepos();
const fetching = $derived(
target.type !== "node" && $fetchingRepos.includes(target.rid),
target.type !== "node" && fetchingRepos.current.includes(target.rid),
);
let repoLocal: boolean | undefined = $state(undefined);
const seedRid = $derived(
@@ -26,13 +26,13 @@
import debounce from "lodash/debounce";
import { useOverlayScrollbars } from "overlayscrollbars-svelte";
import { repoList } from "@app/lib/cobQueries";
import {
cachedAlias,
cachedIssueById,
cachedListIssueCandidates,
cachedListPatchCandidates,
cachedListReleaseCandidates,
cachedListReposSummary,
cachedPatchById,
cachedReleaseById,
cachedRepoById,
@@ -41,6 +41,7 @@
cachedRepoSplitTreePath,
cachedSearchAliases,
} from "@app/lib/invoke";
import { labs } from "@app/lib/labs";
import type { Entity } from "@app/lib/mentions";
import {
describeLink,
@@ -51,6 +52,8 @@
import type { MentionTrigger } from "@app/lib/mentionTrigger";
import { findMentionTrigger } from "@app/lib/mentionTrigger";
import { portal } from "@app/lib/portal";
import { projectsOf } from "@app/lib/projects";
import { queryClient } from "@app/lib/query";
import type { RadReference } from "@app/lib/radUri";
import { fileReference, formatReference, isOid } from "@app/lib/radUri";
import { repoListScope } from "@app/lib/repoListScope";
@@ -569,9 +572,10 @@
}
async function collectRepos(): Promise<Suggestion[]> {
const repos = await cachedListReposSummary(repoListScope.value).catch(
() => [],
);
const repos = await queryClient
.fetchQuery(repoList(repoListScope.value))
.then(list => projectsOf(list.repos, labs.actorRepos))
.catch(() => []);
const ordered = [...repos].sort(
(a, b) =>
Number(b.rid === rid) - Number(a.rid === rid) ||
+5 -2
View File
@@ -5,7 +5,7 @@
import { describeLink, referenceRoute } from "@app/lib/mentions";
import { formatReference, parseReference } from "@app/lib/radUri";
import { push, routeToPath } from "@app/lib/router";
import { fetchingRepos } from "@app/lib/seedRepo";
import { createFetchingRepos } from "@app/lib/seedRepo";
import { explorerLink } from "@app/lib/utils";
import ExplorerMenu, {
@@ -46,7 +46,10 @@
const rid = $derived(
reference?.type === "uri" ? `rad:${reference.uri.repo}` : undefined,
);
const fetching = $derived(rid !== undefined && $fetchingRepos.includes(rid));
const fetchingRepos = createFetchingRepos();
const fetching = $derived(
rid !== undefined && fetchingRepos.current.includes(rid),
);
let local: boolean | undefined = $state(undefined);
$effect(() => {
if (!rid || fetching) return;
+27 -80
View File
@@ -52,38 +52,34 @@
</script>
<script lang="ts">
import type { ReleaseCounts } from "@bindings/cob/release/ReleaseCounts";
import type { Config } from "@bindings/config/Config";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import type { CrossfadeParams } from "svelte/transition";
import { keys } from "@radicle-gui/core/keys";
import RepoAvatar from "@radicle-gui/ui/components/RepoAvatar.svelte";
import { onInvalidate } from "@radicle-gui/ui/lib/query.svelte";
import { onMount, untrack } from "svelte";
import { createQuery, invalidate } from "@radicle-gui/ui/lib/query.svelte";
import { onMount } from "svelte";
import { flip } from "svelte/animate";
import { backOut, cubicOut } from "svelte/easing";
import { get } from "svelte/store";
import { crossfade, fade, scale, slide } from "svelte/transition";
import { releaseCounts, repoList } from "@app/lib/cobQueries";
import { nodeEvents, nodeRunning } from "@app/lib/events";
import type { FlipSnapshot } from "@app/lib/flip";
import { captureFlip, playFlip } from "@app/lib/flip";
import { dynamicInterval, resetDynamicInterval } from "@app/lib/interval";
import {
cachedListReposSummary,
invalidateReposSummary,
invoke,
writeToClipboard,
} from "@app/lib/invoke";
import { invoke, writeToClipboard } from "@app/lib/invoke";
import { labs } from "@app/lib/labs";
import { entityUrl } from "@app/lib/mentions";
import { show } from "@app/lib/modal";
import { motion } from "@app/lib/motion";
import { projectsOf } from "@app/lib/projects";
import { queryClient } from "@app/lib/query";
import { repoListScope } from "@app/lib/repoListScope";
import * as router from "@app/lib/router";
import { seededRepos, seedRepo, setFetchingRepos } from "@app/lib/seedRepo";
import { seedRepo } from "@app/lib/seedRepo";
import {
ariaKeyShortcuts,
modifierHeld,
@@ -116,8 +112,18 @@
config,
}: Props = $props();
let repos: RepoSummary[] = $derived(initialRepos);
let seededNotReplicated: string[] = $derived(initialSeededNotReplicated);
const repoListQuery = createQuery(queryClient, () =>
repoList(repoListScope.value),
);
const repos: RepoSummary[] = $derived(
repoListQuery.current.data
? projectsOf(repoListQuery.current.data.repos, labs.actorRepos)
: initialRepos,
);
const seededNotReplicated: string[] = $derived(
repoListQuery.current.data?.seededNotReplicated ??
initialSeededNotReplicated,
);
let filterInputElement: HTMLInputElement | undefined = $state(undefined);
const shortcutNumbers = $derived(
@@ -201,47 +207,16 @@
return () => resetDynamicInterval("seededNotReplicated");
});
// Kept while navigating inside the repo, so the badge doesn't flicker.
let releaseCount = $state<number | undefined>(undefined);
let countedRid: string | undefined = undefined;
// Bumped when the active repo's releases change, to count them again.
let releasesChanged = $state(0);
onInvalidate(
queryClient,
() => keys.releaseCount(activeRepo?.rid ?? ""),
async () => {
releasesChanged++;
},
const releaseCountQuery = createQuery(queryClient, () => ({
...releaseCounts(activeRepo?.rid ?? ""),
enabled: activeRepo !== undefined,
}));
const releaseCount = $derived(
releaseCountQuery.current.data &&
releaseCountQuery.current.data.delegate +
releaseCountQuery.current.data.other,
);
$effect(() => {
void releasesChanged;
const rid = activeRepo?.rid;
if (rid === undefined) {
releaseCount = undefined;
countedRid = undefined;
return;
}
if (countedRid !== rid) {
releaseCount = undefined;
countedRid = rid;
}
let cancelled = false;
invoke<ReleaseCounts>("release_counts", { rid })
.then(counts => {
if (!cancelled) releaseCount = counts.delegate + counts.other;
})
.catch(() => {
if (!cancelled) releaseCount = undefined;
});
return () => {
cancelled = true;
};
});
const filteredRepos = $derived(
filterQuery.trim()
? repos.filter(r =>
@@ -395,38 +370,10 @@
setOrder: rids => withPinAnimation(() => (pinnedRepoIds.value = rids)),
});
$effect(() => setFetchingRepos(seededNotReplicated));
$effect(() => {
if ($seededRepos === 0) return;
untrack(() => void reloadRepos());
});
// Reloads when a seeded repo arrives, or an identity update renames one.
onInvalidate(queryClient, () => keys.repos(), reloadRepos);
async function reloadRepos() {
invalidateReposSummary();
const [reloaded, fetching] = await Promise.all([
cachedListReposSummary(repoListScope.value),
invoke<string[]>("seeded_not_replicated"),
]);
repos = reloaded;
seededNotReplicated = fetching;
await invalidate(queryClient, { queryKey: keys.repos() });
}
// The route loader already fetched the list for the scope in force, so the
// first run only records it; later runs are the preference actually changing.
let loadedScope: string | undefined;
$effect(() => {
const scope = repoListScope.value;
const first = loadedScope === undefined;
loadedScope = scope;
if (!first) {
untrack(() => void reloadRepos());
}
});
// Ordered like the CLI: drop the seeding policy first, then let storage prune
// what it can. `clean` keeps the local node's and the delegates' refs, so a
// repo we have published to survives in a reduced form. Throws, so each
+27
View File
@@ -4,9 +4,11 @@ import type { Operation } from "@bindings/cob/Operation";
import type { Action as PatchAction } from "@bindings/cob/patch/Action";
import type { Patch } from "@bindings/cob/patch/Patch";
import type { Revision } from "@bindings/cob/patch/Revision";
import type { ReleaseCounts } from "@bindings/cob/release/ReleaseCounts";
import type { Thread } from "@bindings/cob/thread/Thread";
import type { Identity } from "@bindings/identity/Identity";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import type { RepoSummary } from "@bindings/repo/RepoSummary";
import type { Key } from "@radicle-gui/core/keys";
import type { QueryOptions } from "@radicle-gui/ui/lib/query.svelte";
@@ -17,6 +19,31 @@ import { nodeEvents } from "@app/lib/events";
import { invoke } from "@app/lib/invoke";
import { queryClient } from "@app/lib/query";
export interface RepoList {
repos: RepoSummary[];
seededNotReplicated: string[];
}
export function repoList(scope: string): QueryOptions<RepoList> {
return {
queryKey: keys.repoList(scope),
queryFn: async () => {
const [repos, seededNotReplicated] = await Promise.all([
invoke<RepoSummary[]>("list_repos_summary", { show: scope }),
invoke<string[]>("seeded_not_replicated"),
]);
return { repos, seededNotReplicated };
},
};
}
export function releaseCounts(rid: string): QueryOptions<ReleaseCounts> {
return {
queryKey: keys.releaseCount(rid),
queryFn: () => invoke<ReleaseCounts>("release_counts", { rid }),
};
}
export function repoInfo(rid: string): QueryOptions<RepoInfo> {
return {
queryKey: keys.repoInfo(rid),
+4 -31
View File
@@ -12,17 +12,14 @@ import type { Stats } from "@bindings/diff/Stats";
import type { Commit } from "@bindings/repo/Commit";
import type { Job } from "@bindings/repo/Job";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import type { RepoSummary } from "@bindings/repo/RepoSummary";
import type { TreePath } from "@bindings/repo/TreePath";
import { keys } from "@radicle-gui/core/keys";
import { cached } from "@radicle-gui/ui/lib/cached";
import { invalidate } from "@radicle-gui/ui/lib/query.svelte";
import * as tauri from "@tauri-apps/api/core";
import { labs } from "@app/lib/labs";
import { projectsOf } from "@app/lib/projects";
import { queryClient } from "@app/lib/query";
import type { RepoListScope } from "@app/lib/repoListScope";
import { writtenKeys } from "@app/lib/writes";
export async function invoke<T = null>(
@@ -441,34 +438,10 @@ export const cachedGetCommitDiff = cached(
{ max: 100 },
);
/**
* Enumerating repos loads and verifies the identity doc of every repo in
* storage, which takes ~100ms with many repos. The list rarely changes, so it
* is cached with a short TTL; mutations that change it (adding, seeding,
* unseeding) go through invalidateReposSummary().
*/
export const cachedListReposWithActors = cached(
(show: RepoListScope) =>
invoke<RepoSummary[]>("list_repos_summary", { show }),
show => `list_repos_summary:${show}`,
{ max: 2, ttl: 30_000 },
);
/**
* The repositories to list as projects, see `projectsOf`. Whatever lists
* repositories calls this; `cachedListReposWithActors` is for telling what is
* in storage.
*/
export async function cachedListReposSummary(
show: RepoListScope,
): Promise<RepoSummary[]> {
return projectsOf(await cachedListReposWithActors(show), labs.actorRepos);
}
/**
* Finding the local actor scans storage like the repo list does, and every
* route loads it while the lab is on, so it shares the list's caching and
* invalidation; a save or create clears it as well.
* route loads it while the lab is on, so it is cached with a short TTL; a save
* or create clears it through invalidateReposSummary().
*/
export const cachedActor = cached(
() => invoke<ActorInfo | null>("actor"),
@@ -478,8 +451,8 @@ export const cachedActor = cached(
// The sidebar loads the repositories and the actor together, so both go.
export function invalidateReposSummary(): void {
cachedListReposWithActors.clear();
cachedActor.clear();
void queryClient.invalidateQueries({ queryKey: keys.repos() });
}
export async function writeToClipboard(
+16 -16
View File
@@ -20,14 +20,10 @@ import {
import { keys } from "@radicle-gui/core/keys";
import { markLoading } from "@radicle-gui/ui/lib/query.svelte";
import { enterRepo } from "@app/lib/cobQueries";
import {
cachedActor,
cachedListReposSummary,
invoke,
InvokeError,
} from "@app/lib/invoke";
import { enterRepo, repoList } from "@app/lib/cobQueries";
import { cachedActor, invoke, InvokeError } from "@app/lib/invoke";
import { labs } from "@app/lib/labs";
import { projectsOf } from "@app/lib/projects";
import { queryClient } from "@app/lib/query";
import { repoListScope } from "@app/lib/repoListScope";
@@ -106,15 +102,19 @@ export function isLoadedRepoRoute(
}
export async function loadSidebarData(): Promise<SidebarData> {
const [config, repos, notificationCount, seededNotReplicated, lookup] =
await Promise.all([
invoke<Config>("config"),
cachedListReposSummary(repoListScope.value),
invoke<number>("notification_count"),
invoke<string[]>("seeded_not_replicated"),
labs.actorRepos ? loadActor() : { actor: null },
]);
return { config, repos, notificationCount, seededNotReplicated, ...lookup };
const [config, list, notificationCount, lookup] = await Promise.all([
invoke<Config>("config"),
queryClient.fetchQuery(repoList(repoListScope.value)),
invoke<number>("notification_count"),
labs.actorRepos ? loadActor() : { actor: null },
]);
return {
config,
repos: projectsOf(list.repos, labs.actorRepos),
notificationCount,
seededNotReplicated: list.seededNotReplicated,
...lookup,
};
}
// Whatever goes wrong with the actor is shown on the profile page, never
+15 -13
View File
@@ -1,6 +1,9 @@
import { writable } from "svelte/store";
import { createQuery } from "@radicle-gui/ui/lib/query.svelte";
import { invalidateReposSummary, invoke } from "@app/lib/invoke";
import { repoList } from "@app/lib/cobQueries";
import { invoke } from "@app/lib/invoke";
import { queryClient } from "@app/lib/query";
import { repoListScope } from "@app/lib/repoListScope";
import { parseRepositoryId } from "@app/lib/utils";
// Validates a RID typed into the "Seed a repo" form. The form accepts a bare
@@ -25,19 +28,18 @@ export function seedTarget(
return { rid };
}
const seeded = writable(0);
const fetching = writable<string[]>([]);
// Seeded repos that haven't been fetched yet, as the repository list last had
// them. Create it during component initialisation.
export function createFetchingRepos(): { readonly current: string[] } {
const query = createQuery(queryClient, () => repoList(repoListScope.value));
// Bumped whenever a repo is seeded from outside the sidebar, which only polls
// while something is already being fetched.
export const seededRepos = { subscribe: seeded.subscribe };
// Seeded repos that haven't been fetched yet, as the sidebar last polled them.
export const fetchingRepos = { subscribe: fetching.subscribe };
export const setFetchingRepos = fetching.set;
return {
get current() {
return query.current.data?.seededNotReplicated ?? [];
},
};
}
export async function seedRepo(rid: string): Promise<void> {
await invoke<null>("seed", { rid });
invalidateReposSummary();
seeded.update(count => count + 1);
}
+12 -2
View File
@@ -8,9 +8,10 @@ import { listen } from "@tauri-apps/api/event";
import once from "lodash/once";
import { get } from "svelte/store";
import type { RepoList } from "@app/lib/cobQueries";
import { clearEntityCaches, invoke } from "@app/lib/invoke";
import { queryClient } from "@app/lib/query";
import { fetchingRepos } from "@app/lib/seedRepo";
import { repoListScope } from "@app/lib/repoListScope";
import { artifactNodeRunning, nodeEvents, nodeRunning } from "./events";
@@ -51,6 +52,15 @@ function isJobs(key: Key): boolean {
return key[0] === "repo" && key[2] === "jobs";
}
// Whether the repository list has `rid` as seeded but not yet arrived.
function underway(rid: string): boolean {
return (
queryClient
.getQueryData<RepoList>(keys.repoList(repoListScope.value))
?.seededNotReplicated.includes(rid) ?? false
);
}
export function onRefUpdate(update: RefUpdate) {
const affected = affectedKeys(update);
// A key for the whole repository covers its jobs too.
@@ -63,7 +73,7 @@ export function onRefUpdate(update: RefUpdate) {
...affected.filter(key => !isJobs(key)),
// The repository list changes when a seeded repository arrives, or when an
// identity update renames one.
...(get(fetchingRepos).includes(update.rid) ||
...(underway(update.rid) ||
update.refs?.some(ref => ref.endsWith("refs/rad/id"))
? [keys.repos()]
: []),
+31 -15
View File
@@ -1,12 +1,16 @@
<script lang="ts">
import type { ActorInfo } from "@bindings/actor/ActorInfo";
import { createQuery } from "@radicle-gui/ui/lib/query.svelte";
import { untrack } from "svelte";
import { repoList } from "@app/lib/cobQueries";
import { nodeRunning } from "@app/lib/events";
import { poll } from "@app/lib/interval";
import { invoke, InvokeError } from "@app/lib/invoke";
import { fetchingRepos, seededRepos, seedRepo } from "@app/lib/seedRepo";
import { queryClient } from "@app/lib/query";
import { repoListScope } from "@app/lib/repoListScope";
import { seedRepo } from "@app/lib/seedRepo";
import { parseRepositoryId, publicKeyFromDid } from "@app/lib/utils";
import ActorAvatar from "@app/components/ActorAvatar.svelte";
@@ -105,8 +109,15 @@
return () => clearTimeout(timer);
});
const repoListQuery = createQuery(queryClient, () =>
repoList(repoListScope.value),
);
// The seeded repositories that haven't arrived yet.
const underway = $derived(
repoListQuery.current.data?.seededNotReplicated ?? [],
);
const fetching = $derived(
check.status === "missing" && $fetchingRepos.includes(check.rid),
check.status === "missing" && underway.includes(check.rid),
);
// A look at a profile that is still awaited: one at a time, and only an
@@ -137,25 +148,26 @@
// The missing profile whose fetch was asked for or seen on its way.
let awaited: string | undefined;
$effect(() => {
if ($seededRepos === 0) return;
untrack(() => {
if (check.status === "missing") awaited = check.rid;
});
});
// When the list last arrived; the query also notifies as a fetch starts,
// with the list from before it.
let seenList = 0;
// The sidebar looks at what is being fetched once a repository is asked
// for, and every few seconds while any is on its way. An awaited profile
// that is not among them when it has looked may have arrived, however
// quickly the fetch went. One that stays among them is looked up at each
// look, since a copy the node cannot update never leaves them.
// The repository list is fetched again once a repository is seeded, when
// one arrives, and, without the node's events, every few seconds while any
// is on its way. An awaited profile that is not on its way in a new list
// may have arrived, however quickly the fetch went. One that stays on its
// way is looked up at each new list, since a copy the node cannot update
// never arrives.
$effect(() => {
const underway = $fetchingRepos;
const updatedAt = repoListQuery.current.dataUpdatedAt;
const fetchingNow = underway;
untrack(() => {
if (updatedAt === seenList) return;
seenList = updatedAt;
if (check.status !== "missing") return;
if (underway.includes(check.rid)) {
if (fetchingNow.includes(check.rid)) {
if (awaited === check.rid) void lookAgain(check.rid);
awaited = check.rid;
} else if (awaited === check.rid) {
@@ -171,9 +183,12 @@
working = true;
error = undefined;
// Set before seeding, so that the list the seed brings finds it.
awaited = target;
try {
await seedRepo(target);
} catch (e) {
awaited = undefined;
error = describeActorError(e, "Could not fetch the profile.");
} finally {
working = false;
@@ -217,6 +232,7 @@
if (check.status === "stuck") {
error = "Could not remove this device's copy of the profile.";
} else if (check.status === "missing" && $nodeRunning) {
awaited = id;
await seedRepo(id);
}
} catch (e) {
+5 -8
View File
@@ -7,9 +7,9 @@
import { listReleases, RELEASES_PER_PAGE } from "@app/views/repo/router";
import { keys } from "@radicle-gui/core/keys";
import { onInvalidate } from "@radicle-gui/ui/lib/query.svelte";
import { createQuery, onInvalidate } from "@radicle-gui/ui/lib/query.svelte";
import { invoke } from "@app/lib/invoke";
import { releaseCounts as releaseCountsQuery } from "@app/lib/cobQueries";
import { modalStore, show } from "@app/lib/modal";
import { createPaginatedList } from "@app/lib/paginatedList.svelte";
import { queryClient } from "@app/lib/query";
@@ -43,7 +43,8 @@
showFilters,
}: Props = $props();
let releaseCounts = $derived(loadedCounts);
const counts = createQuery(queryClient, () => releaseCountsQuery(repo.rid));
const releaseCounts = $derived(counts.current.data ?? loadedCounts);
const delegateIds = $derived(new Set(repo.delegates.map(d => d.did)));
@@ -60,11 +61,7 @@
});
async function refresh() {
const [, counts] = await Promise.all([
list.revalidate(Math.max(list.items.length, RELEASES_PER_PAGE)),
invoke<ReleaseCounts>("release_counts", { rid: repo.rid }),
]);
releaseCounts = counts;
await list.refresh();
}
// The paginated list keeps its own pages, so the cache only tells it when
+6 -10
View File
@@ -31,6 +31,7 @@ import {
issueDetail,
load,
patchDetail,
releaseCounts,
repoInfo,
} from "@app/lib/cobQueries";
import {
@@ -395,10 +396,7 @@ async function loadSourceContext(route: {
peer?: string;
revision?: string;
}): Promise<SourceContext> {
markLoading(
queryClient,
keys.headLoaded(route.rid, route.peer, route.revision),
);
markLoading(queryClient, keys.head(route.rid, route.peer, route.revision));
const [sidebarData, repo, commit] = await Promise.all([
loadSidebarData(),
load(repoInfo(route.rid)),
@@ -582,17 +580,15 @@ export async function loadReleases(
): Promise<LoadedRepoReleasesRoute> {
const scope = route.scope ?? "trusted";
markLoading(queryClient, keys.releaseList(route.rid, scope));
const [sidebarData, repo, releases, releaseCounts] = await Promise.all([
const [sidebarData, repo, releases, counts] = await Promise.all([
loadSidebarData(),
load(repoInfo(route.rid)),
listReleases(route.rid, scope, 0, RELEASES_PER_PAGE),
invoke<ReleaseCounts>("release_counts", {
rid: route.rid,
}),
load(releaseCounts(route.rid)),
]);
// Others is one click away whenever it has releases, and Delegates is one
// click back from it; see docs/adr/0004.
const showFilters = scope === "untrusted" || releaseCounts.other > 0;
const showFilters = scope === "untrusted" || counts.other > 0;
return {
resource: "repo.releases",
@@ -600,7 +596,7 @@ export async function loadReleases(
sidebarData,
repo,
releases,
releaseCounts,
releaseCounts: counts,
scope,
showFilters,
},
+3 -5
View File
@@ -9,13 +9,11 @@ const { invalidateQueries, clearEntityCaches } = vi.hoisted(() => ({
invalidateQueries: vi.fn(),
clearEntityCaches: vi.fn(),
}));
vi.mock("@app/lib/query", () => ({ queryClient: { invalidateQueries } }));
vi.mock("@app/lib/query", () => ({
queryClient: { invalidateQueries, getQueryData: vi.fn() },
}));
vi.mock("@app/lib/invoke", () => ({ clearEntityCaches, invoke: vi.fn() }));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn() }));
vi.mock("@app/lib/seedRepo", async () => {
const { writable } = await import("svelte/store");
return { fetchingRepos: writable([]) };
});
const rid = "rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5";
-16
View File
@@ -12,22 +12,6 @@ export const keys = {
// The commit a revision resolves to; no revision means the default branch.
head: (rid: string, peer: string | undefined, revision: string | undefined) =>
["repo", rid, "code", "head", peer ?? "", revision ?? ""] as const,
// When a route last resolved that revision, so that a ref update during the
// load can tell the view to check the head again.
headLoaded: (
rid: string,
peer: string | undefined,
revision: string | undefined,
) =>
[
"repo",
rid,
"code",
"head",
peer ?? "",
revision ?? "",
"loaded",
] as const,
issues: (rid: string) => ["repo", rid, "issues"] as const,
// One status's list; `status` is the filter as the view names it.
issueList: (rid: string, status: string) =>