fix: "Check Quota Now" button not refreshing UI after polling (#42)
* feat: add React Query hooks for managing cloud accounts and update the generated route tree. * feat: implement React Query hooks for comprehensive cloud account management. * fix(cloud-accounts): add error handling to force poll mutation Add an onError handler to log failures when forcing a cloud monitor poll, improving debuggability. * fix: add error handling for cloud account polling failure Add error toast notification when force polling fails, providing localized error message to improve user feedback. * refactor: remove error logging from force poll cloud monitor hook The onError handler was removed as error handling is now managed at a higher level in the application. This simplifies the hook and prevents duplicate error logging. * fix(localization): add missing pollFailed translation keys Add missing English and Chinese translations for the 'pollFailed' error message used when quota polling fails for all accounts. * fix(CloudAccountList): prevent duplicate force poll requests Add guard clause to disable button while mutation is pending to avoid duplicate API calls. * fix: ensure UI updates after cloud quota poll and refresh * chore: remove "peer": true flags from package-lock.json --------- Co-authored-by: Draculabo <[email protected]>
This commit is contained in:
1 parent
5a2168030e
commit
e959ee346e
7 files changed
+21
-217
No files matched your search
@@ -47,12 +47,12 @@ export function useRefreshQuota() {
|
||||
return useMutation({
|
||||
mutationFn: refreshAccountQuota,
|
||||
onSuccess: (updatedAccount: CloudAccount) => {
|
||||
// Optimistically update the list or just invalidate?
|
||||
// Invalidating is safer as sorting might change (last_used)
|
||||
// Optimistically update
|
||||
queryClient.setQueryData(QUERY_KEYS.cloudAccounts, (oldData: CloudAccount[] | undefined) => {
|
||||
if (!oldData) return [updatedAccount];
|
||||
return oldData.map((acc) => (acc.id === updatedAccount.id ? updatedAccount : acc));
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: QUERY_KEYS.cloudAccounts });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -97,8 +97,12 @@ export function useSetAutoSwitchEnabled() {
|
||||
}
|
||||
|
||||
export function useForcePollCloudMonitor() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: forcePollCloudMonitor,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: QUERY_KEYS.cloudAccounts });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user