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.
This commit is contained in:
QuentinHsu
2026-06-15 14:53:23 +08:00
committed by GitHub
parent 3c1bb0a74f
commit aeea3fae9b
2 changed files with 6 additions and 4 deletions
@@ -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 || []