From 008af5487df7e971108c2c37f745e1132b85a34b Mon Sep 17 00:00:00 2001 From: Raj Dave Date: Mon, 15 Dec 2025 16:19:33 +0300 Subject: [PATCH] Invalidates backup schedule queries on reorder Ensures the backup schedule list is refreshed after reordering, both on success and on error, by using the dedicated query key instead of a generic string. This guarantees the UI reflects the latest state. --- app/client/modules/backups/routes/backups.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/client/modules/backups/routes/backups.tsx b/app/client/modules/backups/routes/backups.tsx index 929da13c..764ba0ec 100644 --- a/app/client/modules/backups/routes/backups.tsx +++ b/app/client/modules/backups/routes/backups.tsx @@ -19,7 +19,7 @@ import { Button } from "~/client/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/client/components/ui/card"; import type { Route } from "./+types/backups"; import { listBackupSchedules } from "~/client/api-client"; -import { listBackupSchedulesOptions } from "~/client/api-client/@tanstack/react-query.gen"; +import { listBackupSchedulesOptions, listBackupSchedulesQueryKey } from "~/client/api-client/@tanstack/react-query.gen"; // Temporary helper until API client is regenerated async function reorderBackupSchedules(scheduleIds: number[]) { @@ -88,7 +88,11 @@ export default function Backups({ loaderData }: Route.ComponentProps) { await reorderBackupSchedules(scheduleIds); }, onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["listBackupSchedules"] }); + queryClient.invalidateQueries({ queryKey: listBackupSchedulesQueryKey() }); + }, + onError: () => { + // Revert the order or display error to user + queryClient.invalidateQueries({ queryKey: listBackupSchedulesQueryKey() }); }, });