Skip to content

Commit 3340eeb

Browse files
committed
feat: Bust cache after restarting a cluster
1 parent fc5a12e commit 3340eeb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/hooks/useRestartClusterClick.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { excludeFalsy } from '@/lib/arrays/excludeFalsy';
77
import { pluralize } from '@/lib/pluralize';
88
import { sleep } from '@/lib/sleep';
99
import { getOperationsUrlForInstance } from '@/lib/urls/getOperationsUrlForInstance';
10+
import { useQueryClient } from '@tanstack/react-query';
1011
import { useParams } from '@tanstack/react-router';
1112
import { useCallback, useState } from 'react';
1213
import { toast } from 'sonner';
@@ -22,6 +23,7 @@ interface RestartClusterClickResponse {
2223

2324
export function useRestartClusterClick({ onRestartedSuccessfully }: RestartClusterClickParams = {}): RestartClusterClickResponse {
2425
const { clusterId }: { clusterId?: string; } = useParams({ strict: false });
26+
const queryClient = useQueryClient();
2527
const [isRestartPending, setIsRestartPending] = useState(false);
2628
const onRestartClick = useCallback(async () => {
2729
if (!clusterId) {
@@ -99,6 +101,7 @@ export function useRestartClusterClick({ onRestartedSuccessfully }: RestartClust
99101
}
100102

101103
setIsRestartPending(false);
104+
void queryClient.invalidateQueries({ queryKey: [clusterId] });
102105

103106
if (canceled) {
104107
toast.error('Cancelled', {

0 commit comments

Comments
 (0)