mirror of
https://github.com/SigNoz/signoz.git
synced 2026-05-26 11:50:31 +01:00
Revert "fix(alerts): move toggle toast to per-call mutate callbacks"
This reverts commit 7dacb99536ca386a9b74d101f2f84fdd39ce6864.
This commit is contained in:
@@ -408,17 +408,7 @@ export const useAlertRuleStatusToggle = ({
|
||||
[REACT_QUERY_KEY.TOGGLE_ALERT_STATE, ruleId],
|
||||
(args: { id: string; data: Partial<RuletypesPostableRuleDTO> }) =>
|
||||
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<RenderErrorResponseDTO>) as APIError,
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const handleAlertStateToggle = (): void => {
|
||||
const args = {
|
||||
id: ruleId,
|
||||
data: { disabled: alertRuleState !== 'disabled' },
|
||||
};
|
||||
toggleAlertState(args);
|
||||
};
|
||||
|
||||
return { handleAlertStateToggle };
|
||||
|
||||
Reference in New Issue
Block a user