Avoid blocking settings on CLI Apps catalog refresh

This commit is contained in:
chengyongru
2026-06-22 17:14:13 +08:00
committed by Xubin Ren
parent 7b153c5aa9
commit b8abe5542c
6 changed files with 243 additions and 33 deletions
+21 -12
View File
@@ -695,22 +695,31 @@ export function SettingsView({
useEffect(() => {
if (activeSection !== "apps") return;
let cancelled = false;
setCliAppsLoading(true);
fetchCliApps(token)
.then((payload) => {
if (!cancelled) {
let retry: number | null = null;
const loadCliApps = (showLoading: boolean) => {
if (showLoading) setCliAppsLoading(true);
fetchCliApps(token)
.then((payload) => {
if (cancelled) return;
if (payload.catalog_refresh_pending) {
retry = window.setTimeout(() => loadCliApps(false), 2000);
if (payload.apps.length === 0) return;
}
setCliApps(payload);
setCliAppsError(null);
}
})
.catch((err) => {
if (!cancelled) setCliAppsError((err as Error).message);
})
.finally(() => {
if (!cancelled) setCliAppsLoading(false);
});
setCliAppsLoading(false);
})
.catch((err) => {
if (!cancelled) {
setCliAppsError((err as Error).message);
setCliAppsLoading(false);
}
});
};
loadCliApps(true);
return () => {
cancelled = true;
if (retry !== null) window.clearTimeout(retry);
};
}, [activeSection, token]);
+1
View File
@@ -605,6 +605,7 @@ export interface CliAppsPayload {
apps: CliAppInfo[];
installed_count: number;
catalog_updated_at?: string | null;
catalog_refresh_pending?: boolean;
last_action?: {
ok: boolean;
message: string;