mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Add robust loading cleanup
Ensure Resolve button clears loading state with proper try-catch-finally around async resolution, preventing stuck loading indicator and improving error handling.
This commit is contained in:
@@ -66,14 +66,20 @@ export function PipelineHealthAlerts() {
|
|||||||
if (error) {
|
if (error) {
|
||||||
console.error('❌ Error resolving alert:', error);
|
console.error('❌ Error resolving alert:', error);
|
||||||
toast.error('Failed to resolve alert');
|
toast.error('Failed to resolve alert');
|
||||||
} else {
|
return;
|
||||||
console.log('✅ Alert resolved successfully');
|
|
||||||
toast.success('Alert resolved');
|
|
||||||
|
|
||||||
// Invalidate queries to refresh the UI
|
|
||||||
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemAlerts() });
|
|
||||||
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemHealth() });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('✅ Alert resolved successfully');
|
||||||
|
toast.success('Alert resolved');
|
||||||
|
|
||||||
|
// Invalidate queries to refresh the UI
|
||||||
|
await Promise.all([
|
||||||
|
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemAlerts() }),
|
||||||
|
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemHealth() })
|
||||||
|
]);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('❌ Unexpected error resolving alert:', err);
|
||||||
|
toast.error('An unexpected error occurred');
|
||||||
} finally {
|
} finally {
|
||||||
setResolvingAlertId(null);
|
setResolvingAlertId(null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user