fix: fetchAppWithTags may return empty when apps is over 100 (#23350)

This commit is contained in:
NeatGuyCoding
2025-08-04 20:20:43 +08:00
committed by GitHub
parent 60c7663a80
commit a724f35672
3 changed files with 13 additions and 31 deletions

View File

@@ -9,7 +9,12 @@ export const fetchAppList: Fetcher<AppListResponse, { url: string; params?: Reco
return get<AppListResponse>(url, { params })
}
export const fetchAppDetail = ({ url, id }: { url: string; id: string }) => {
export const fetchAppDetail: Fetcher<AppDetailResponse, { url: string; id: string }> = ({ url, id }) => {
return get<AppDetailResponse>(`${url}/${id}`)
}
// Direct API call function for non-SWR usage
export const fetchAppDetailDirect = async ({ url, id }: { url: string; id: string }): Promise<AppDetailResponse> => {
return get<AppDetailResponse>(`${url}/${id}`)
}
@@ -60,21 +65,6 @@ export const deleteApp: Fetcher<CommonResponse, string> = (appID) => {
return del<CommonResponse>(`apps/${appID}`)
}
export const fetchAppWithTags = async (appID: string) => {
try {
const appListResponse = await fetchAppList({
url: '/apps',
params: { page: 1, limit: 100 },
})
const appWithTags = appListResponse.data.find(app => app.id === appID)
return appWithTags || null
}
catch (error) {
console.warn('Failed to fetch app with tags:', error)
return null
}
}
export const updateAppSiteStatus: Fetcher<AppDetailResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
return post<AppDetailResponse>(url, { body })
}