()
+
+ const handleUpldateMarketplaceCollections = useCallback(async () => {
setIsLoading(true)
const { marketplaceCollections, marketplaceCollectionPluginsMap } = await getMarketplaceCollectionsAndPlugins()
setIsLoading(false)
+
setMarketplaceCollections(marketplaceCollections)
setMarketplaceCollectionPluginsMap(marketplaceCollectionPluginsMap)
+ setPlugins(undefined)
}, [])
+
+ const handleUpdatePlugins = async (query: PluginsSearchParams) => {
+ setIsLoading(true)
+ const { marketplacePlugins } = await getMarketplacePlugins(query)
+ setIsLoading(false)
+
+ setPlugins(marketplacePlugins)
+ }
+
+ const { run: handleUpdatePluginsWithDebounced } = useDebounceFn(handleUpdatePlugins, {
+ wait: 500,
+ })
+
useEffect(() => {
- getMarketplaceCollections()
- }, [getMarketplaceCollections])
+ if (searchPluginText || filterPluginTags.length) {
+ if (searchPluginText) {
+ handleUpdatePluginsWithDebounced({
+ query: searchPluginText,
+ tags: filterPluginTags,
+ })
+ return
+ }
+ handleUpdatePlugins({
+ query: searchPluginText,
+ tags: filterPluginTags,
+ })
+ }
+ else {
+ handleUpldateMarketplaceCollections()
+ }
+ }, [searchPluginText, filterPluginTags, handleUpdatePluginsWithDebounced, handleUpldateMarketplaceCollections])
return {
isLoading,
marketplaceCollections,
marketplaceCollectionPluginsMap,
+ plugins,
}
}
diff --git a/web/app/components/tools/marketplace/index.tsx b/web/app/components/tools/marketplace/index.tsx
index 64ec83f460..2bb935db14 100644
--- a/web/app/components/tools/marketplace/index.tsx
+++ b/web/app/components/tools/marketplace/index.tsx
@@ -4,16 +4,21 @@ import List from '@/app/components/plugins/marketplace/list'
import Loading from '@/app/components/base/loading'
type MarketplaceProps = {
+ searchPluginText: string
+ filterPluginTags: string[]
onMarketplaceScroll: () => void
}
const Marketplace = ({
+ searchPluginText,
+ filterPluginTags,
onMarketplaceScroll,
}: MarketplaceProps) => {
const {
isLoading,
marketplaceCollections,
marketplaceCollectionPluginsMap,
- } = useMarketplace()
+ plugins,
+ } = useMarketplace(searchPluginText, filterPluginTags)
return (
@@ -55,6 +60,7 @@ const Marketplace = ({
)
diff --git a/web/app/components/tools/provider-list.tsx b/web/app/components/tools/provider-list.tsx
index 24baf9f0e1..acec3dad7e 100644
--- a/web/app/components/tools/provider-list.tsx
+++ b/web/app/components/tools/provider-list.tsx
@@ -126,9 +126,13 @@ const ProviderList = () => {
{
enable_marketplace && (
- {
- containerRef.current?.scrollTo({ top: containerRef.current.scrollHeight, behavior: 'smooth' })
- }} />
+ {
+ containerRef.current?.scrollTo({ top: containerRef.current.scrollHeight, behavior: 'smooth' })
+ }}
+ searchPluginText={keywords}
+ filterPluginTags={tagFilterValue}
+ />
)
}