diff --git a/web/app/components/plugins/install-plugin/base/use-get-icon.ts b/web/app/components/plugins/install-plugin/base/use-get-icon.ts index ea7f8e36b9..bb46f27f53 100644 --- a/web/app/components/plugins/install-plugin/base/use-get-icon.ts +++ b/web/app/components/plugins/install-plugin/base/use-get-icon.ts @@ -1,19 +1,12 @@ +import { useCallback } from 'react' import { apiPrefix } from '@/config' -import { fetchWorkspaces } from '@/service/common' - -let tenantId: string | null | undefined = null +import { useSelector } from '@/context/app-context' const useGetIcon = () => { - const getIconUrl = async (fileName: string) => { - if (!tenantId) { - const { workspaces } = await fetchWorkspaces({ - url: '/workspaces', - params: {}, - }) - tenantId = workspaces.find(v => v.current)?.id - } - return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${tenantId}&filename=${fileName}` - } + const currentWorkspace = useSelector(s => s.currentWorkspace) + const getIconUrl = useCallback((fileName: string) => { + return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${currentWorkspace.id}&filename=${fileName}` + }, [currentWorkspace.id]) return { getIconUrl, diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx index 6f4c8f390c..2ea822df42 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx +++ b/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx @@ -20,6 +20,7 @@ import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' import CardIcon from '@/app/components/plugins/card/base/card-icon' import cn from '@/utils/classnames' import { useGetLanguage } from '@/context/i18n' +import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' const PluginTasks = () => { const { t } = useTranslation() @@ -32,6 +33,7 @@ const PluginTasks = () => { totalPluginsLength, handleClearErrorPlugin, } = usePluginTaskStatus() + const { getIconUrl } = useGetIcon() const isInstalling = runningPlugins.length > 0 && errorPlugins.length === 0 && successPlugins.length === 0 const isInstallingWithError = errorPlugins.length > 0 && errorPlugins.length < totalPluginsLength @@ -123,7 +125,8 @@ const PluginTasks = () => {