From fd9616cc2dfce86214eb4e9571ccc69fa75c1e17 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 25 Jul 2024 22:44:18 +0530 Subject: [PATCH] feat: emit mousedown only if !getText --- src/components/atoms/canvas.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/atoms/canvas.tsx b/src/components/atoms/canvas.tsx index 139abc7e..bfd801f6 100644 --- a/src/components/atoms/canvas.tsx +++ b/src/components/atoms/canvas.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useRef } from 'react'; import { useSocketStore } from '../../context/socket'; import { getMappedCoordinates } from "../../helpers/inputHelpers"; import { useGlobalInfoStore } from "../../context/globalInfo"; +import { useActionContext } from '../../context/browserActions'; interface CreateRefCallback { (ref: React.RefObject): void; @@ -26,6 +27,7 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => { const canvasRef = useRef(null); const { socket } = useSocketStore(); const { setLastAction, lastAction } = useGlobalInfoStore(); + const { getText, getScreenshot } = useActionContext(); const notifyLastAction = (action: string) => { if (lastAction !== action) { @@ -45,8 +47,11 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => { switch (event.type) { case 'mousedown': const clickCoordinates = getMappedCoordinates(event, canvasRef.current, width, height); - // needed for navigation - socket.emit('input:mousedown', clickCoordinates); + if (getText === true) { + console.log('get text') + } else { + socket.emit('input:mousedown', clickCoordinates); + } notifyLastAction('click'); break; case 'mousemove': @@ -78,7 +83,7 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => { return; } } - }, [socket]); + }, [socket, getText]); const onKeyboardEvent = useCallback((event: KeyboardEvent) => { if (socket) {