feat: use notify last action

This commit is contained in:
karishmas6
2024-07-23 20:09:30 +05:30
parent e575e3733b
commit 152c5501b3

View File

@@ -69,7 +69,7 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
lastMousePosition.current.y !== coordinates.y) { lastMousePosition.current.y !== coordinates.y) {
lastMousePosition.current = coordinates; lastMousePosition.current = coordinates;
socket.emit('input:mousemove', coordinates); socket.emit('input:mousemove', coordinates);
setLastAction('move'); notifyLastAction('move');
} }
break; break;
case 'mousedown': case 'mousedown':
@@ -85,11 +85,11 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
setShowConfirmation(true); setShowConfirmation(true);
} else { } else {
socket.emit('input:mousedown', coordinates); socket.emit('input:mousedown', coordinates);
setLastAction('click'); notifyLastAction('click');
} }
} else { } else {
socket.emit('input:mousedown', coordinates); socket.emit('input:mousedown', coordinates);
setLastAction('click'); notifyLastAction('click');
} }
break; break;
case 'wheel': case 'wheel':
@@ -99,7 +99,7 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
deltaY: Math.round(wheelEvent.deltaY), deltaY: Math.round(wheelEvent.deltaY),
}; };
socket.emit('input:wheel', deltas); socket.emit('input:wheel', deltas);
setLastAction('scroll'); notifyLastAction('scroll');
break; break;
} }
} }
@@ -110,7 +110,7 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
switch (event.type) { switch (event.type) {
case 'keydown': case 'keydown':
socket.emit('input:keydown', { key: event.key, coordinates: lastMousePosition.current }); socket.emit('input:keydown', { key: event.key, coordinates: lastMousePosition.current });
setLastAction(`${event.key} pressed`); notifyLastAction(`${event.key} pressed`);
break; break;
case 'keyup': case 'keyup':
socket.emit('input:keyup', event.key); socket.emit('input:keyup', event.key);
@@ -122,7 +122,7 @@ const Canvas = ({ width, height, onCreateRef, highlighterData }: CanvasProps) =>
const handleConfirmation = (confirmed: boolean) => { const handleConfirmation = (confirmed: boolean) => {
if (confirmed && pendingClick && socket) { if (confirmed && pendingClick && socket) {
socket.emit('input:mousedown', pendingClick); socket.emit('input:mousedown', pendingClick);
setLastAction('click'); notifyLastAction('click');
} }
setShowConfirmation(false); setShowConfirmation(false);
setPendingClick(null); setPendingClick(null);