feat: emit mousedown only if !getText
This commit is contained in:
@@ -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<HTMLCanvasElement>): void;
|
||||
@@ -26,6 +27,7 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
||||
const canvasRef = useRef<HTMLCanvasElement>(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) {
|
||||
|
||||
Reference in New Issue
Block a user