From 64de6a17f508b40a776cc72c8b489586ebe17dd1 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 4 Oct 2025 15:21:20 +0000 Subject: [PATCH] improve insert module button menu caching --- .../flows/content/FlowInputsQuick.svelte | 87 ++++++++++++------- .../flows/map/InsertModuleInner.svelte | 3 +- .../flows/pickers/PickHubScriptQuick.svelte | 11 ++- .../pickers/WorkspaceScriptPickerQuick.svelte | 23 ++--- 4 files changed, 77 insertions(+), 47 deletions(-) diff --git a/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte b/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte index 761035d3ab..d40d3a7fe5 100644 --- a/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte +++ b/frontend/src/lib/components/flows/content/FlowInputsQuick.svelte @@ -1,14 +1,17 @@ + + @@ -164,6 +164,7 @@ {disableAi} {funcDesc} {kind} + bind:owners on:close={() => { dispatch('close') }} diff --git a/frontend/src/lib/components/flows/pickers/PickHubScriptQuick.svelte b/frontend/src/lib/components/flows/pickers/PickHubScriptQuick.svelte index 879dbed29c..e618e13762 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubScriptQuick.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubScriptQuick.svelte @@ -4,6 +4,7 @@ IntegrationService.listHubIntegrations({ kind }), { initial: { kind: 'script', refreshCount: 0 }, invalidateMs: 1000 * 60 } ) + console.log('listHubIntegrationsCached', listHubIntegrationsCached) let listHubScriptsCached = createCache( async ({ filter, @@ -15,9 +16,11 @@ appFilter: string | undefined refreshCount?: number }) => - filter.length > 0 - ? await ScriptService.queryHubScripts({ text: filter, limit: 40, kind }) - : ((await ScriptService.getTopHubScripts({ limit: 40, kind, app: appFilter })).asks ?? []), + get(userStore) + ? filter.length > 0 + ? await ScriptService.queryHubScripts({ text: filter, limit: 40, kind }) + : ((await ScriptService.getTopHubScripts({ limit: 40, kind, app: appFilter })).asks ?? []) + : undefined, { initial: { filter: '', kind: 'script', appFilter: undefined, refreshCount: 0 }, invalidateMs: 1000 * 60 @@ -34,6 +37,8 @@ import { Circle } from 'lucide-svelte' import Popover from '$lib/components/Popover.svelte' import { usePromise } from '$lib/svelte5Utils.svelte' + import { userStore } from '$lib/stores' + import { get } from 'svelte/store' let hubNotAvailable = $state(false) diff --git a/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte b/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte index 7141c0f816..c4df0772d3 100644 --- a/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte +++ b/frontend/src/lib/components/flows/pickers/WorkspaceScriptPickerQuick.svelte @@ -11,7 +11,7 @@ isTemplate?: boolean refreshCount?: number }) => - workspace + workspace && get(userStore) ? kind == 'flow' ? FlowService.listFlows({ workspace }) : ScriptService.listScripts({ workspace, kinds: kind, isTemplate }) @@ -42,6 +42,7 @@ import Popover from '$lib/components/Popover.svelte' import { usePromise } from '$lib/svelte5Utils.svelte' import { get } from 'svelte/store' + import { userStore } from '$lib/stores' type Item = { path: string @@ -114,17 +115,19 @@ } }) $effect(() => { - owners = Array.from( - new Set(filteredItems?.map((x) => x.path.split('/').slice(0, 2).join('/')) ?? []) - ).sort((a, b) => { - if (a.startsWith('u/') && !b.startsWith('u/')) return -1 - if (b.startsWith('u/') && !a.startsWith('u/')) return 1 + if (filteredItems) { + owners = Array.from( + new Set(filteredItems?.map((x) => x.path.split('/').slice(0, 2).join('/')) ?? []) + ).sort((a, b) => { + if (a.startsWith('u/') && !b.startsWith('u/')) return -1 + if (b.startsWith('u/') && !a.startsWith('u/')) return 1 - if (a.startsWith('f/') && !b.startsWith('f/')) return -1 - if (b.startsWith('f/') && !a.startsWith('f/')) return 1 + if (a.startsWith('f/') && !b.startsWith('f/')) return -1 + if (b.startsWith('f/') && !a.startsWith('f/')) return 1 - return a.localeCompare(b) - }) + return a.localeCompare(b) + }) + } }) $effect(() => { filteredWithOwner =