desktop: Refresh the repo list when seeded repos arrive

A seeded repo appears as soon as the node has fetched it, instead of on
the next five-second poll.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:16 +01:00
parent 9b6854ae55
commit 0475a2cea7
3 changed files with 17 additions and 3 deletions
@@ -57,14 +57,16 @@
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 { flip } from "svelte/animate";
import { backOut, cubicOut } from "svelte/easing";
import { get } from "svelte/store";
import { crossfade, fade, scale, slide } from "svelte/transition";
import { nodeRunning } from "@app/lib/events";
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";
@@ -78,6 +80,7 @@
import { entityUrl } from "@app/lib/mentions";
import { show } from "@app/lib/modal";
import { motion } from "@app/lib/motion";
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";
@@ -185,8 +188,9 @@
}
});
// Without the node's events, poll while a seeded repo hasn't arrived yet.
$effect(() => {
if (seededNotReplicated.length > 0) {
if (seededNotReplicated.length > 0 && !$nodeEvents) {
dynamicInterval("seededNotReplicated", reloadRepos, 5_000);
} else {
resetDynamicInterval("seededNotReplicated");
@@ -388,6 +392,9 @@
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([
+7 -1
View File
@@ -10,6 +10,7 @@ import { get } from "svelte/store";
import { invoke } from "@app/lib/invoke";
import { queryClient } from "@app/lib/query";
import { fetchingRepos } from "@app/lib/seedRepo";
import { artifactNodeRunning, nodeEvents, nodeRunning } from "./events";
@@ -19,7 +20,6 @@ function batch(delay: number): (affected: Key[]) => void {
const pending = new Map<string, Key>();
let flush: ReturnType<typeof setTimeout> | undefined;
return affected => {
if (affected.length === 0) return;
for (const key of affected) pending.set(key.join("\0"), key);
flush ??= setTimeout(() => {
flush = undefined;
@@ -40,6 +40,12 @@ function onRefUpdate(update: RefUpdate) {
...affectedKeys(update),
// The node writes notifications as it fetches.
keys.notificationCount(),
// The repository list changes when a seeded repository arrives, or when an
// identity update renames one.
...(get(fetchingRepos).includes(update.rid) ||
update.refs?.some(ref => ref.endsWith("refs/rad/id"))
? [keys.repos()]
: []),
]);
}
+1
View File
@@ -16,6 +16,7 @@ export const keys = {
patchList: (rid: string, status: string) =>
["repo", rid, "patches", status] as const,
patch: (rid: string, id: string) => ["repo", rid, "patch", id] as const,
repos: () => ["repos"] as const,
notificationCount: () => ["notifications", "count"] as const,
};