From 86624e847eefac8e83f671a57e90dc43630ada8f Mon Sep 17 00:00:00 2001 From: Calvin Koepke Date: Tue, 17 Dec 2024 11:08:45 -0700 Subject: [PATCH] chore: cleanup cancel func --- ui/src/components/Graph/modules/Controls.tsx | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ui/src/components/Graph/modules/Controls.tsx b/ui/src/components/Graph/modules/Controls.tsx index f1820aa5..4b9e507f 100644 --- a/ui/src/components/Graph/modules/Controls.tsx +++ b/ui/src/components/Graph/modules/Controls.tsx @@ -1,4 +1,4 @@ -import { FC, memo } from "react"; +import { FC, memo, useCallback } from "react"; import { defaultAggregatedData, useGraphContext } from "@/contexts/GraphContext/context"; import { useHandlers } from "../hooks/useHandlers"; @@ -9,6 +9,19 @@ export const Controls: FC = memo(() => { const { handleResetSim } = useHandlers(); const { startStream, streaming, stopStream } = useStreamMessagesHandler(); + const handleCancelSim = useCallback(() => { + () => { + stopStream(); + dispatch({ + type: "BATCH_UPDATE", + payload: { + currentNode: undefined, + aggregatedData: defaultAggregatedData, + }, + }); + } + }, [stopStream, dispatch]) + return (