-
-
+
+
diff --git a/web/app/components/plugins/marketplace/list/index.tsx b/web/app/components/plugins/marketplace/list/index.tsx
index 05abd04653..cd703c9180 100644
--- a/web/app/components/plugins/marketplace/list/index.tsx
+++ b/web/app/components/plugins/marketplace/list/index.tsx
@@ -14,6 +14,7 @@ type ListProps = {
locale: string
cardContainerClassName?: string
cardRender?: (plugin: Plugin) => JSX.Element | null
+ onMoreClick?: () => void
}
const List = ({
marketplaceCollections,
@@ -23,6 +24,7 @@ const List = ({
locale,
cardContainerClassName,
cardRender,
+ onMoreClick,
}: ListProps) => {
return (
<>
@@ -35,6 +37,7 @@ const List = ({
locale={locale}
cardContainerClassName={cardContainerClassName}
cardRender={cardRender}
+ onMoreClick={onMoreClick}
/>
)
}
diff --git a/web/app/components/plugins/marketplace/list/list-with-collection.tsx b/web/app/components/plugins/marketplace/list/list-with-collection.tsx
index 512a34c383..4bb22ad4dc 100644
--- a/web/app/components/plugins/marketplace/list/list-with-collection.tsx
+++ b/web/app/components/plugins/marketplace/list/list-with-collection.tsx
@@ -12,6 +12,7 @@ type ListWithCollectionProps = {
locale: string
cardContainerClassName?: string
cardRender?: (plugin: Plugin) => JSX.Element | null
+ onMoreClick?: () => void
}
const ListWithCollection = ({
marketplaceCollections,
@@ -20,6 +21,7 @@ const ListWithCollection = ({
locale,
cardContainerClassName,
cardRender,
+ // onMoreClick,
}: ListWithCollectionProps) => {
return (
<>
@@ -29,8 +31,16 @@ const ListWithCollection = ({
key={collection.name}
className='py-3'
>
-
{collection.label[getLanguage(locale)]}
-
{collection.description[getLanguage(locale)]}
+
+
+
{collection.label[getLanguage(locale)]}
+
{collection.description[getLanguage(locale)]}
+
+ {/*
onMoreClick?.()}
+ >more
*/}
+
{
+ searchPluginTextRef.current = searchPluginText
+ filterPluginTagsRef.current = filterPluginTags
+ }, [searchPluginText, filterPluginTags])
useEffect(() => {
if ((searchPluginText || filterPluginTags.length) && isSuccess) {
+ setPage(1)
+ pageRef.current = 1
+
if (searchPluginText) {
queryPluginsWithDebounced({
category: PluginType.tool,
@@ -39,6 +54,7 @@ export const useMarketplace = (searchPluginText: string, filterPluginTags: strin
tags: filterPluginTags,
exclude,
type: 'plugin',
+ page: pageRef.current,
})
return
}
@@ -48,6 +64,7 @@ export const useMarketplace = (searchPluginText: string, filterPluginTags: strin
tags: filterPluginTags,
exclude,
type: 'plugin',
+ page: pageRef.current,
})
}
else {
@@ -63,10 +80,38 @@ export const useMarketplace = (searchPluginText: string, filterPluginTags: strin
}
}, [searchPluginText, filterPluginTags, queryPlugins, queryMarketplaceCollectionsAndPlugins, queryPluginsWithDebounced, resetPlugins, exclude, isSuccess])
+ const handleScroll = useCallback((e: Event) => {
+ const target = e.target as HTMLDivElement
+ const {
+ scrollTop,
+ scrollHeight,
+ clientHeight,
+ } = target
+ if (scrollTop + clientHeight >= scrollHeight - 5 && scrollTop > 0) {
+ const searchPluginText = searchPluginTextRef.current
+ const filterPluginTags = filterPluginTagsRef.current
+ if (pluginsTotal && plugins && pluginsTotal > plugins.length && (!!searchPluginText || !!filterPluginTags.length)) {
+ setPage(pageRef.current + 1)
+ pageRef.current++
+
+ queryPlugins({
+ category: PluginType.tool,
+ query: searchPluginText,
+ tags: filterPluginTags,
+ exclude,
+ type: 'plugin',
+ page: pageRef.current,
+ })
+ }
+ }
+ }, [exclude, plugins, pluginsTotal, queryPlugins])
+
return {
isLoading: isLoading || isPluginsLoading,
marketplaceCollections,
marketplaceCollectionPluginsMap,
plugins,
+ handleScroll,
+ page,
}
}
diff --git a/web/app/components/tools/marketplace/index.tsx b/web/app/components/tools/marketplace/index.tsx
index 71cac1f781..7fa307c556 100644
--- a/web/app/components/tools/marketplace/index.tsx
+++ b/web/app/components/tools/marketplace/index.tsx
@@ -1,3 +1,7 @@
+import {
+ useEffect,
+ useRef,
+} from 'react'
import {
RiArrowRightUpLine,
RiArrowUpDoubleLine,
@@ -21,15 +25,33 @@ const Marketplace = ({
}: MarketplaceProps) => {
const locale = getLocaleOnClient()
const { t } = useTranslation()
+
const {
isLoading,
marketplaceCollections,
marketplaceCollectionPluginsMap,
plugins,
+ handleScroll,
+ page,
} = useMarketplace(searchPluginText, filterPluginTags)
+ const containerRef = useRef
(null)
+
+ useEffect(() => {
+ const container = containerRef.current
+ if (container)
+ container.addEventListener('scroll', handleScroll)
+
+ return () => {
+ if (container)
+ container.removeEventListener('scroll', handleScroll)
+ }
+ }, [handleScroll])
return (
-
+
onMarketplaceScroll()}
@@ -67,14 +89,14 @@ const Marketplace = ({
{
- isLoading && (
+ isLoading && page === 1 && (
)
}
{
- !isLoading && (
+ (!isLoading || page > 1) && (
{
{(filteredCollectionList.length > 0 || activeTab !== 'builtin') && (
{activeTab === 'api' && }
{filteredCollectionList.map(collection => (
@@ -125,7 +125,7 @@ const ProviderList = () => {
)}
{!filteredCollectionList.length && activeTab === 'builtin' && (
-
+
)}
{
enable_marketplace && activeTab === 'builtin' && (