refactor: add API endpoint to list latest plugin versions and query it in a asynchronous way (#17695)

This commit is contained in:
Yeuoly
2025-04-09 18:49:27 +09:00
committed by GitHub
parent 2c2efe2e1e
commit 33324ee23d
6 changed files with 67 additions and 23 deletions

View File

@@ -9,6 +9,7 @@ import type {
Dependency,
GitHubItemAndMarketPlaceDependency,
InstallPackageResponse,
InstalledLatestVersionResponse,
InstalledPluginListResponse,
PackageDependency,
Permissions,
@@ -72,6 +73,19 @@ export const useInstalledPluginList = (disable?: boolean) => {
})
}
export const useInstalledLatestVersion = (pluginIds: string[]) => {
return useQuery<InstalledLatestVersionResponse>({
queryKey: [NAME_SPACE, 'installedLatestVersion', pluginIds],
queryFn: () => post<InstalledLatestVersionResponse>('/workspaces/current/plugin/list/latest-versions', {
body: {
plugin_ids: pluginIds,
},
}),
enabled: !!pluginIds.length,
initialData: pluginIds.length ? undefined : { versions: {} },
})
}
export const useInvalidateInstalledPluginList = () => {
const queryClient = useQueryClient()
const invalidateAllBuiltInTools = useInvalidateAllBuiltInTools()