@@ -64,17 +64,34 @@ export const usePackages = (appId: number) => {
6464
6565export const useVersions = ( {
6666 appId,
67- offset,
68- limit,
67+ offset = 0 ,
68+ limit = 10 ,
6969} : {
7070 appId : number ;
7171 offset ?: number ;
7272 limit ?: number ;
7373} ) => {
74+ // Fetch all versions (up to 1000) from backend and cache them
7475 const { data, isLoading } = useQuery ( {
75- queryKey : [ "versions" , appId , offset , limit ] ,
76- staleTime : 0 ,
77- queryFn : ( ) => api . getVersions ( { appId, offset, limit } ) ,
76+ queryKey : [ "versions" , appId ] ,
77+ staleTime : 3000 ,
78+ queryFn : ( ) => api . getVersions ( { appId, offset : 0 , limit : 1000 } ) ,
7879 } ) ;
79- return { versions : data ?. data ?? [ ] , count : data ?. count ?? 0 , isLoading } ;
80+
81+ // Implement frontend pagination
82+ const allVersions = data ?. data ?? [ ] ;
83+ const totalCount = data ?. count ?? 0 ;
84+
85+ // Calculate pagination
86+ const startIndex = offset ;
87+ const endIndex = offset + limit ;
88+ const paginatedVersions = allVersions . slice ( startIndex , endIndex ) ;
89+
90+ return {
91+ versions : paginatedVersions ,
92+ count : totalCount ,
93+ isLoading,
94+ // Also return all versions for components that might need them
95+ allVersions,
96+ } ;
8097} ;
0 commit comments