diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx index d55ea4de85..71f81f0ffa 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx @@ -7,7 +7,7 @@ import type { InstallState } from '@/app/components/plugins/types' import { useGitHubReleases } from '../hooks' import { convertRepoToUrl, parseGitHubUrl } from '../utils' import type { PluginDeclaration, UpdateFromGitHubPayload } from '../../types' -import { InstallStepFromGitHub, PluginType } from '../../types' +import { InstallStepFromGitHub } from '../../types' import Toast from '@/app/components/base/toast' import SetURL from './steps/setURL' import SelectPackage from './steps/selectPackage' @@ -15,8 +15,7 @@ import Installed from '../base/installed' import Loaded from './steps/loaded' import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' import { useTranslation } from 'react-i18next' -import { useUpdateModelProviders } from '@/app/components/header/account-setting/model-provider-page/hooks' -import { useInvalidateAllToolProviders } from '@/service/use-tools' +import useRefreshPluginList from '../hooks/use-refresh-plugin-list' const i18nPrefix = 'plugin.installFromGitHub' @@ -30,8 +29,8 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on const { t } = useTranslation() const { getIconUrl } = useGetIcon() const { fetchReleases } = useGitHubReleases() - const updateModelProviders = useUpdateModelProviders() - const invalidateAllToolProviders = useInvalidateAllToolProviders() + const { refreshPluginList } = useRefreshPluginList() + const [state, setState] = useState({ step: updatePayload ? InstallStepFromGitHub.selectPackage : InstallStepFromGitHub.setUrl, repoUrl: updatePayload?.originalPackageInfo?.repo @@ -115,14 +114,9 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on const handleInstalled = useCallback(() => { setState(prevState => ({ ...prevState, step: InstallStepFromGitHub.installed })) - if (!manifest) - return - if (PluginType.model.includes(manifest.category)) - updateModelProviders() - if (PluginType.tool.includes(manifest.category)) - invalidateAllToolProviders() + refreshPluginList(manifest) onSuccess() - }, [invalidateAllToolProviders, manifest, onSuccess, updateModelProviders]) + }, [manifest, onSuccess, refreshPluginList]) const handleFailed = useCallback((errorMsg?: string) => { setState(prevState => ({ ...prevState, step: InstallStepFromGitHub.installFailed })) diff --git a/web/app/components/plugins/plugin-page/empty/index.tsx b/web/app/components/plugins/plugin-page/empty/index.tsx index 408f724df7..3263f6a0c3 100644 --- a/web/app/components/plugins/plugin-page/empty/index.tsx +++ b/web/app/components/plugins/plugin-page/empty/index.tsx @@ -8,7 +8,7 @@ import { usePluginPageContext } from '../context' import { Group } from '@/app/components/base/icons/src/vender/other' import { useSelector as useAppContextSelector } from '@/context/app-context' import Line from '../../marketplace/empty/line' -import { useInstalledPluginList, useInvalidateInstalledPluginList } from '@/service/use-plugins' +import { useInstalledPluginList } from '@/service/use-plugins' import { useTranslation } from 'react-i18next' import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config' @@ -29,14 +29,13 @@ const Empty = () => { } const filters = usePluginPageContext(v => v.filters) const { data: pluginList } = useInstalledPluginList() - const invalidateInstalledPluginList = useInvalidateInstalledPluginList() const text = useMemo(() => { if (pluginList?.plugins.length === 0) return t('plugin.list.noInstalled') if (filters.categories.length > 0 || filters.tags.length > 0 || filters.searchQuery) return t('plugin.list.notFound') - }, [pluginList, filters]) + }, [pluginList?.plugins.length, t, filters.categories.length, filters.tags.length, filters.searchQuery]) return (
@@ -100,7 +99,7 @@ const Empty = () => {
{selectedAction === 'github' && { invalidateInstalledPluginList() }} + onSuccess={() => { }} onClose={() => setSelectedAction(null)} />} {selectedAction === 'local' && selectedFile diff --git a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx index e8d68e1bbf..4c2d543e14 100644 --- a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx +++ b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx @@ -15,7 +15,6 @@ import { PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import { useSelector as useAppContextSelector } from '@/context/app-context' -import { useInvalidateInstalledPluginList } from '@/service/use-plugins' import { useTranslation } from 'react-i18next' import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config' @@ -31,7 +30,6 @@ const InstallPluginDropdown = ({ const [selectedAction, setSelectedAction] = useState(null) const [selectedFile, setSelectedFile] = useState(null) const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures) - const invalidateInstalledPluginList = useInvalidateInstalledPluginList() const handleFileChange = (event: React.ChangeEvent) => { const file = event.target.files?.[0] @@ -120,7 +118,7 @@ const InstallPluginDropdown = ({ {selectedAction === 'github' && { invalidateInstalledPluginList() }} + onSuccess={() => { }} onClose={() => setSelectedAction(null)} />} {selectedAction === 'local' && selectedFile