@@ -78,6 +78,29 @@ export const workflowsApi = api.injectEndpoints({
78
78
} ) ,
79
79
providesTags : [ 'FetchOnReconnect' , { type : 'Workflow' , id : LIST_TAG } ] ,
80
80
} ) ,
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
+ } ) ,
81
104
setWorkflowThumbnail : build . mutation < void , { workflow_id : string ; image : File } > ( {
82
105
query : ( { workflow_id, image } ) => {
83
106
const formData = new FormData ( ) ;
@@ -113,6 +136,7 @@ export const {
113
136
useDeleteWorkflowMutation,
114
137
useUpdateWorkflowMutation,
115
138
useListWorkflowsQuery,
139
+ useListWorkflowsInfiniteInfiniteQuery,
116
140
useSetWorkflowThumbnailMutation,
117
141
useDeleteWorkflowThumbnailMutation,
118
142
} = workflowsApi ;
0 commit comments