Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Show a new site audit in the list without a page reload (EVE-257) (#654)
Carter Smithc3d70bf51e87
diff --git a/src/client/features/audit/launch/useLaunchController.ts b/src/client/features/audit/launch/useLaunchController.tsindex cb25cc6e..61522f77 100644--- a/src/client/features/audit/launch/useLaunchController.ts+++ b/src/client/features/audit/launch/useLaunchController.ts@@ -1,5 +1,5 @@import { useForm } from "@tanstack/react-form";-import { useMutation, useQuery } from "@tanstack/react-query";+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import {deleteAudit,@@ -50,11 +50,13 @@ export function useLaunchController({const historyQuery = useQuery({queryKey: ["audit-history", projectId],queryFn: () => getAuditHistory({ data: { projectId } }),+ // Keep in-progress rows live so status and page counts don't need a reload.+ refetchInterval: (query) =>+ query.state.data?.some((audit) => audit.status === "running")+ ? 5000+ : false,});- const { startMutation, deleteMutation } = useLaunchMutations({- projectId,- historyRefetch: historyQuery.refetch,- });+ const { startMutation, deleteMutation } = useLaunchMutations({ projectId });const launchForm = useForm({defaultValues: DEFAULT_LAUNCH_FORM_VALUES,@@ -107,13 +109,13 @@ export function useLaunchController({};}-function useLaunchMutations({- projectId,- historyRefetch,-}: {- projectId: string;- historyRefetch: () => Promise<unknown>;-}) {+function useLaunchMutations({ projectId }: { projectId: string }) {+ const queryClient = useQueryClient();+ // Invalidate rather than refetch: starting an audit navigates away from the+ // list, so the stale mark is what makes it reload when the user comes back.+ const invalidateHistory = () =>+ queryClient.invalidateQueries({ queryKey: ["audit-history", projectId] });+const startMutation = useMutation({mutationFn: (data: {projectId: string;@@ -121,13 +123,16 @@ function useLaunchMutations({maxPages: number;lighthouseStrategy: "auto" | "none";}) => startAudit({ data }),+ onSuccess: () => {+ void invalidateHistory();+ },});const deleteMutation = useMutation({mutationFn: (auditId: string) =>deleteAudit({ data: { projectId, auditId } }),onSuccess: () => {- void historyRefetch();+ void invalidateHistory();toast.success("Audit deleted");},});