From 0af646d947bca8d4f2fe183bf30fb2eb904d75ec Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 27 Jun 2025 19:35:18 +0800 Subject: [PATCH] fix: fetch installed plugin instead of all plugins --- .../auto-update-setting/tool-item.tsx | 7 +++-- .../auto-update-setting/tool-picker.tsx | 28 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx b/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx index f60faa734f..99a01bcd0f 100644 --- a/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx +++ b/web/app/components/plugins/reference-setting-modal/auto-update-setting/tool-item.tsx @@ -1,7 +1,7 @@ 'use client' import type { FC } from 'react' import React from 'react' -import type { Plugin } from '@/app/components/plugins/types' +import type { PluginDetail } from '@/app/components/plugins/types' import Icon from '@/app/components/plugins/card/base/card-icon' import { renderI18nObject } from '@/i18n' import { useGetLanguage } from '@/context/i18n' @@ -9,7 +9,7 @@ import { MARKETPLACE_API_PREFIX } from '@/config' import Checkbox from '@/app/components/base/checkbox' type Props = { - payload: Plugin + payload: PluginDetail isChecked?: boolean onCheckChange: () => void } @@ -21,7 +21,8 @@ const ToolItem: FC = ({ }) => { const language = useGetLanguage() - const { plugin_id, label, org } = payload + const { plugin_id, declaration } = payload + const { label, author: org } = declaration return (
= ({ const [pluginType, setPluginType] = useState(PLUGIN_TYPE_SEARCH_MAP.all) const [query, setQuery] = useState('') const [tags, setTags] = useState([]) - const { data, isLoading } = useFetchPluginListOrBundleList({ - query, - tags, - category: pluginType, - }) - const isBundle = pluginType === PLUGIN_TYPE_SEARCH_MAP.bundle - const list = (isBundle ? data?.data?.bundles : data?.data?.plugins) || [] + const { data, isLoading } = useInstalledPluginList() + const filteredList = useMemo(() => { + const list = data ? data.plugins : [] + return list.filter((plugin) => { + return ( + (pluginType === PLUGIN_TYPE_SEARCH_MAP.all || plugin.declaration.category === pluginType) + && (tags.length === 0 || tags.some(tag => plugin.declaration.tags.includes(tag))) + && (query === '' || plugin.plugin_id.toLowerCase().includes(query.toLowerCase())) + ) + }) + }, [data, pluginType, query, tags]) const handleCheckChange = useCallback((pluginId: string) => { return () => { const newValue = value.includes(pluginId) @@ -84,7 +88,7 @@ const ToolPicker: FC = ({ const listContent = (
- {list.map(item => ( + {filteredList.map(item => ( = ({ }
- {!isLoading && list.length > 0 && listContent} - {!isLoading && list.length === 0 && noData} + {!isLoading && filteredList.length > 0 && listContent} + {!isLoading && filteredList.length === 0 && noData} {isLoading && loadingContent}