From e575e3733bd890cb0cb909f4488999ae8e4e9d28 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 23 Jul 2024 20:08:40 +0530 Subject: [PATCH] feat: notify last action --- src/components/atoms/canvas.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/atoms/canvas.tsx b/src/components/atoms/canvas.tsx index b0a65fba..520c6d0b 100644 --- a/src/components/atoms/canvas.tsx +++ b/src/components/atoms/canvas.tsx @@ -47,12 +47,18 @@ const ConfirmationBox = ({ selector, onYes, onNo }: { selector: string; onYes: ( const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) => { const canvasRef = useRef(null); const { socket } = useSocketStore(); - const { setLastAction } = useGlobalInfoStore(); + const { setLastAction, lastAction } = useGlobalInfoStore(); const [showConfirmation, setShowConfirmation] = useState(false); const [pendingClick, setPendingClick] = useState(null); const lastMousePosition = useRef({ x: 0, y: 0 }); + const notifyLastAction = (action: string) => { + if (lastAction !== action) { + setLastAction(action); + } + }; + const onMouseEvent = useCallback((event: MouseEvent) => { if (socket && canvasRef.current) { const coordinates = getMappedCoordinates(event, canvasRef.current, width, height);