@@ -160,7 +180,7 @@ const ViewHistory = ({
)
}
{
- data?.data.map(item => (
+ allRuns.map(item => (
))
}
+ {hasNextPage && (
+
+ {isFetchingNextPage && }
+
+ )}
)
}
diff --git a/web/service/use-workflow.ts b/web/service/use-workflow.ts
index 103e3b77b0..e1fc4241a2 100644
--- a/web/service/use-workflow.ts
+++ b/web/service/use-workflow.ts
@@ -27,13 +27,25 @@ export const useAppWorkflow = (appID: string) => {
}
const WorkflowRunHistoryKey = [NAME_SPACE, 'runHistory']
+const WORKFLOW_RUN_HISTORY_LIMIT = 20
export const useWorkflowRunHistory = (url?: string, enabled = true) => {
- return useQuery
({
+ return useInfiniteQuery({
queryKey: [...WorkflowRunHistoryKey, url],
- queryFn: () => get(url as string),
+ queryFn: ({ pageParam }) => get(url as string, {
+ params: {
+ limit: WORKFLOW_RUN_HISTORY_LIMIT,
+ ...(pageParam ? { last_id: pageParam } : {}),
+ },
+ }),
enabled: !!url && enabled,
staleTime: 0,
+ initialPageParam: undefined as string | undefined,
+ getNextPageParam: (lastPage) => {
+ if (!lastPage.has_more || !lastPage.data.length)
+ return undefined
+ return lastPage.data[lastPage.data.length - 1].id
+ },
})
}
diff --git a/web/types/workflow.ts b/web/types/workflow.ts
index 95d8e47fdb..15595f7631 100644
--- a/web/types/workflow.ts
+++ b/web/types/workflow.ts
@@ -398,6 +398,8 @@ export type WorkflowRunHistory = {
}
export type WorkflowRunHistoryResponse = {
data: WorkflowRunHistory[]
+ has_more: boolean
+ limit: number
}
export type NodesDefaultConfigsResponse = {