diff --git a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte index ef2b752e4b..a1ca1a167c 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte @@ -84,40 +84,21 @@ startTs = ts await new Promise((r) => setTimeout(r, 100)) if (ts < startTs) return - let scripts: any[] - if (filter.length > 0) { - try { - scripts = await ScriptService.queryHubScripts({ - text: `${filter}`, - limit: 20, - kind: filterKind, - app: appFilter - }) - } catch { - // Fallback: load top scripts and filter client-side - const top = - ( + const scripts = + filter.length > 0 + ? await ScriptService.queryHubScripts({ + text: `${filter}`, + limit: 20, + kind: filterKind, + app: appFilter + }) + : (( await ScriptService.getTopHubScripts({ - limit: 40, + limit: 20, app: appFilter, kind: filterKind }) - ).asks ?? [] - const lc = filter.toLowerCase() - scripts = top.filter( - (x: any) => x.summary?.toLowerCase().includes(lc) || x.app?.toLowerCase().includes(lc) - ) - } - } else { - scripts = - ( - await ScriptService.getTopHubScripts({ - limit: 20, - app: appFilter, - kind: filterKind - }) - ).asks ?? [] - } + ).asks ?? []) if (ts === startTs) { loading = false } @@ -131,7 +112,7 @@ kind: HubScriptKind }) => ({ ...x, - path: `hub/${x.version_id}/${x.app}/${(x.summary ?? '').toLowerCase().replaceAll(/\s+/g, '_')}`, + path: `hub/${x.version_id}/${x.app}/${x.summary.toLowerCase().replaceAll(/\s+/g, '_')}`, summary: `${x.summary} (${x.app})` }) )