From 23a119dc3b4e145101fdeb4a2e024387a04c0548 Mon Sep 17 00:00:00 2001 From: Igor Loskutov Date: Wed, 3 Sep 2025 13:11:20 -0400 Subject: [PATCH] invalidate room on room update --- www/app/lib/apiHooks.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/www/app/lib/apiHooks.ts b/www/app/lib/apiHooks.ts index 348e7c73..94d84c9b 100644 --- a/www/app/lib/apiHooks.ts +++ b/www/app/lib/apiHooks.ts @@ -162,10 +162,21 @@ export function useRoomUpdate() { const queryClient = useQueryClient(); return $api.useMutation("patch", "/v1/rooms/{room_id}", { - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: $api.queryOptions("get", "/v1/rooms").queryKey, - }); + onSuccess: async (room) => { + await Promise.all([ + queryClient.invalidateQueries({ + queryKey: $api.queryOptions("get", "/v1/rooms").queryKey, + }), + queryClient.invalidateQueries({ + queryKey: $api.queryOptions("get", "/v1/rooms/{room_id}", { + params: { + path: { + room_id: room.id, + }, + }, + }).queryKey, + }), + ]); }, onError: (error) => { setError(error as Error, "There was an error updating the room");