@@ -78,6 +78,29 @@ export const workflowsApi = api.injectEndpoints({
7878 } ) ,
7979 providesTags : [ 'FetchOnReconnect' , { type : 'Workflow' , id : LIST_TAG } ] ,
8080 } ) ,
81+ listWorkflowsInfinite : build . infiniteQuery <
82+ paths [ '/api/v1/workflows/' ] [ 'get' ] [ 'responses' ] [ '200' ] [ 'content' ] [ 'application/json' ] ,
83+ NonNullable < paths [ '/api/v1/workflows/' ] [ 'get' ] [ 'parameters' ] [ 'query' ] > ,
84+ number
85+ > ( {
86+ query : ( { queryArg, pageParam } ) => ( {
87+ url : `${ buildWorkflowsUrl ( ) } ?${ queryString . stringify ( { ...queryArg , page : pageParam } , { arrayFormat : 'none' } ) } ` ,
88+ } ) ,
89+ infiniteQueryOptions : {
90+ initialPageParam : 0 ,
91+ getNextPageParam : ( _lastPage , _allPages , lastPageParam , _allPageParams ) => {
92+ const finalPage = _lastPage . pages - 1 ;
93+ const remainingPages = finalPage - lastPageParam ;
94+ if ( remainingPages > 0 ) {
95+ return lastPageParam + 1 ;
96+ }
97+ return undefined ;
98+ } ,
99+ getPreviousPageParam : ( _firstPage , _allPages , firstPageParam , _allPageParams ) => {
100+ return firstPageParam > - 1 ? firstPageParam - 1 : undefined ;
101+ } ,
102+ } ,
103+ } ) ,
81104 setWorkflowThumbnail : build . mutation < void , { workflow_id : string ; image : File } > ( {
82105 query : ( { workflow_id, image } ) => {
83106 const formData = new FormData ( ) ;
@@ -113,6 +136,7 @@ export const {
113136 useDeleteWorkflowMutation,
114137 useUpdateWorkflowMutation,
115138 useListWorkflowsQuery,
139+ useListWorkflowsInfiniteInfiniteQuery,
116140 useSetWorkflowThumbnailMutation,
117141 useDeleteWorkflowThumbnailMutation,
118142} = workflowsApi ;
0 commit comments