Merge pull request #20186 from ramonlsouza/cursor-up

fix: only send cursor updates of users with whiteboard access
This commit is contained in:
Ramón Souza 2024-05-07 13:07:20 -03:00 committed by GitHub
commit bacf1e4fcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -343,7 +343,7 @@ const Whiteboard = React.memo(function Whiteboard(props) {
const { updated } = changes;
const { "pointer:pointer": pointers } = updated;
if (pointers) {
if ((isPresenter || hasWBAccessRef.current) && pointers) {
const [prevPointer, nextPointer] = pointers;
updateCursorPosition(nextPointer?.x, nextPointer?.y);
}

View File

@ -1,13 +1,16 @@
import React, { useState, useEffect } from 'react';
const useCursor = (publishCursorUpdate, whiteboardId) => {
const [cursorPosition, setCursorPosition] = useState({ x: -1, y: -1 });
const [cursorPosition, setCursorPosition] = useState({ x: '', y: '' });
const updateCursorPosition = (newX, newY) => {
setCursorPosition({ x: newX, y: newY });
};
useEffect(() => {
if (!cursorPosition || cursorPosition.x === '' || cursorPosition.y === '') {
return;
}
publishCursorUpdate({
whiteboardId,
xPercent: cursorPosition?.x,