refactor: add API endpoint to list latest plugin versions and query it in a asynchronous way (#17695)
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user