From 406800a2e5c45d4bf00a63ab97ecc339b94d030b Mon Sep 17 00:00:00 2001 From: Jatinderjit Singh Date: Thu, 21 May 2026 14:40:38 +0530 Subject: [PATCH] Revert "fix(alerts): move toggle toast to per-call mutate callbacks" This reverts commit 7dacb99536ca386a9b74d101f2f84fdd39ce6864. --- frontend/src/pages/AlertDetails/hooks.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/frontend/src/pages/AlertDetails/hooks.tsx b/frontend/src/pages/AlertDetails/hooks.tsx index d41b672263..31117bc2b4 100644 --- a/frontend/src/pages/AlertDetails/hooks.tsx +++ b/frontend/src/pages/AlertDetails/hooks.tsx @@ -408,17 +408,7 @@ export const useAlertRuleStatusToggle = ({ [REACT_QUERY_KEY.TOGGLE_ALERT_STATE, ruleId], (args: { id: string; data: Partial }) => patchRulePartial(args.id, args.data), - ); - - const handleAlertStateToggle = (): void => { - const args = { - id: ruleId, - data: { disabled: alertRuleState !== 'disabled' }, - }; - // Per-call callbacks: react-query v3 invokes these exactly once per - // mutate() — unlike hook-level onSuccess which can re-fire when the - // MutationObserver re-subscribes during context-driven re-renders. - toggleAlertState(args, { + { onSuccess: (data) => { setAlertRuleState(data.data.state); invalidateGetRuleByID(queryClient, { id: ruleId }); @@ -436,7 +426,15 @@ export const useAlertRuleStatusToggle = ({ convertToApiError(error as AxiosError) as APIError, ); }, - }); + }, + ); + + const handleAlertStateToggle = (): void => { + const args = { + id: ruleId, + data: { disabled: alertRuleState !== 'disabled' }, + }; + toggleAlertState(args); }; return { handleAlertStateToggle };