diff --git a/src/pages/instances/Events.tsx b/src/pages/instances/Events.tsx index 373d4ac450..5c3cff0910 100644 --- a/src/pages/instances/Events.tsx +++ b/src/pages/instances/Events.tsx @@ -2,10 +2,13 @@ import React, { FC, useEffect, useState } from "react"; import { LxdEvent } from "types/event"; import { useEventQueue } from "context/eventQueue"; import { useAuth } from "context/auth"; +import { useQueryClient } from "@tanstack/react-query"; +import { queryKeys } from "util/queryKeys"; const Events: FC = () => { const { isAuthenticated } = useAuth(); const eventQueue = useEventQueue(); + const queryClient = useQueryClient(); const [eventWs, setEventWs] = useState(null); const handleEvent = (event: LxdEvent) => { @@ -40,6 +43,11 @@ const Events: FC = () => { return; } const event = JSON.parse(message.data) as LxdEvent; + if (event.type === "operation") { + void queryClient.invalidateQueries({ + queryKey: [queryKeys.operations, event.project], + }); + } setTimeout(() => handleEvent(event), 1000); // handle with delay to allow operations to vanish }; }; diff --git a/src/pages/instances/InstanceList.tsx b/src/pages/instances/InstanceList.tsx index 391729bf66..2cc37c7554 100644 --- a/src/pages/instances/InstanceList.tsx +++ b/src/pages/instances/InstanceList.tsx @@ -114,7 +114,6 @@ const InstanceList: FC = () => { const { data: operationList } = useQuery({ queryKey: [queryKeys.operations, project], queryFn: () => fetchOperations(project), - refetchInterval: 1000, }); if (error) {