M-029 Pass 1 batch 2: migrate 5 two-mutation pages to useTrackedMutation

Drains 10 more useMutation sites (52 -> 42). Each migration declares explicit

invalidates per the M-009 contract.

Pages migrated:

  - DashboardPage.tsx        previewDigest + sendDigest both 'noop' (read-only

                              preview / fire-and-forget email — no client cache impact)

  - DiscoveryPage.tsx        claim + dismiss both invalidate

                              [['discovered-certificates'], ['discovery-summary']]

  - NotificationsPage.tsx    markRead + requeue both invalidate [['notifications']]

  - TargetDetailPage.tsx     update + testConnection both invalidate [['target', id]]

  - TargetsPage.tsx          createTarget + deleteTarget both invalidate [['targets']]

Verification:

  legacy useMutation count   52 -> 42 (-10)

  useTrackedMutation count    4 -> 14 (+10)

Closes 14 of 56 sites toward M-029 Pass 1 completion.
This commit is contained in:
Shankar
2026-04-27 02:40:54 +00:00
parent fd493c5907
commit 73c6883a15
5 changed files with 34 additions and 31 deletions
+10 -3
View File
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { useQuery, useMutation } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { useTrackedMutation } from '../hooks/useTrackedMutation';
import { useNavigate, useSearchParams } from 'react-router-dom';
import {
BarChart, Bar, LineChart, Line, PieChart, Pie, Cell,
@@ -81,15 +82,21 @@ function DigestCard() {
const [previewHtml, setPreviewHtml] = useState<string | null>(null);
const [showPreview, setShowPreview] = useState(false);
const previewMutation = useMutation({
const previewMutation = useTrackedMutation({
mutationFn: previewDigest,
invalidates: 'noop',
noopReason: 'previewDigest is read-only — server renders HTML; no cached query touched',
onSuccess: (html) => {
setPreviewHtml(html);
setShowPreview(true);
},
});
const sendMutation = useMutation({ mutationFn: sendDigest });
const sendMutation = useTrackedMutation({
mutationFn: sendDigest,
invalidates: 'noop',
noopReason: 'sendDigest dispatches an email server-side; no cached client query reflects digest-send state',
});
return (
<>