From eff6a5596051f17e840074addf142bfce88b8ec8 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Thu, 9 Jan 2025 11:53:24 +0800 Subject: [PATCH] fix: install button --- .../_base/components/install-plugin-button.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx b/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx index bf4073358f..dc5930e15b 100644 --- a/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx +++ b/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx @@ -17,17 +17,19 @@ export const InstallPluginButton = (props: InstallPluginButtonProps) => { pluginIds: [uniqueIdentifier], enabled: !!uniqueIdentifier, }) - const install = useInstallPackageFromMarketPlace({ - onSuccess() { - manifest.refetch() - onSuccess?.() - }, - }) + const install = useInstallPackageFromMarketPlace() + const isLoading = manifest.isLoading || install.isPending + // await for refetch to get the new installed plugin, when manifest refetch, this component will unmount + || install.isSuccess const handleInstall: MouseEventHandler = (e) => { e.stopPropagation() - install.mutate(uniqueIdentifier) + install.mutate(uniqueIdentifier, { + onSuccess: async () => { + await manifest.refetch() + onSuccess?.() + }, + }) } - const isLoading = manifest.isLoading || install.isPending if (!manifest.data) return null if (manifest.data.plugins.some(plugin => plugin.id === uniqueIdentifier)) return null return