diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx index 3e4ad67555..aab791d8d3 100644 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx @@ -158,6 +158,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) { const whiteboardIdRef = React.useRef(whiteboardId); const curPageIdRef = React.useRef(curPageId); const hasWBAccessRef = React.useRef(hasWBAccess); + const isModeratorRef = React.useRef(isModerator); const THRESHOLD = 0.1; const lastKnownHeight = React.useRef(presentationAreaHeight); @@ -169,6 +170,10 @@ export default Whiteboard = React.memo(function Whiteboard(props) { curPageIdRef.current = curPageId; }, [curPageId]); + React.useEffect(() => { + isModeratorRef.current = isModerator; + }, [isModerator]); + React.useEffect(() => { whiteboardIdRef.current = whiteboardId; }, [whiteboardId]); @@ -268,7 +273,11 @@ export default Whiteboard = React.memo(function Whiteboard(props) { typeName: remoteShape.typeName, }; - if (!selectedShapeIds.includes(remoteShape.id) && prevShape?.meta?.updatedBy !== currentUser?.userId) { + if ( + (prevShape?.meta?.updatedBy !== currentUser?.userId && !selectedShapeIds.includes(remoteShape.id)) || + (prevShape?.meta?.createdBy === currentUser?.userId) || + (prevShape?.meta?.createdBy !== currentUser?.userId && selectedShapeIds.includes(remoteShape.id) && (isPresenter || isModeratorRef.current)) + ) { Object.keys(remoteShape).forEach((key) => { if (key !== "isModerator" && !isEqual(remoteShape[key], localShape[key])) { diff[key] = remoteShape[key]; @@ -855,7 +864,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) { createdBy: currentUser?.userId, }, }; - persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModerator); + persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModeratorRef.current); }); Object.values(updated).forEach(([_, record]) => { @@ -867,7 +876,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) { updatedBy: currentUser?.userId, }, }; - persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModerator); + persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModeratorRef.current); }); Object.values(removed).forEach((record) => { @@ -972,7 +981,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) { editor.store.onBeforeChange = (prev, next, source) => { if (next?.typeName === "instance_page_state") { - if ((isPresenter || isModerator)) return next; + if (isPresenter || isModeratorRef.current) return next; // Filter selectedShapeIds based on shape owner if (next.selectedShapeIds.length > 0 && !isEqual(prev.selectedShapeIds, next.selectedShapeIds)) { @@ -1033,7 +1042,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {