Commit aeea3fae by QuentinHsu Committed by GitHub

fix(keys): refresh API key form options (#5512)

- enable model and group queries only while the API key drawer is open and remove the five-minute stale window so the form uses fresh backend options.
- align the API key table group-ratio query key to avoid duplicate caches for the same group endpoint.
parent 3c1bb0a7
......@@ -49,9 +49,9 @@ function getQuotaProgressColor(percentage: number): string {
function useGroupRatios(): Record<string, number> {
const { data } = useQuery({
queryKey: ['user-self-groups'],
queryKey: ['user-groups'],
queryFn: getUserGroups,
staleTime: 5 * 60 * 1000,
staleTime: 0,
select: (res) => {
if (!res.success || !res.data) return {}
const ratios: Record<string, number> = {}
......
......@@ -104,14 +104,16 @@ export function ApiKeysMutateDrawer({
const { data: modelsData } = useQuery({
queryKey: ['user-models'],
queryFn: getUserModels,
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
enabled: open,
staleTime: 0,
})
// Fetch groups
const { data: groupsData } = useQuery({
queryKey: ['user-groups'],
queryFn: getUserGroups,
staleTime: 5 * 60 * 1000,
enabled: open,
staleTime: 0,
})
const models = modelsData?.data || []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment