Merge pull request #19688 from KDSBrowne/bbb30-multi-draw-crash

fix(whiteboard): Prevent Crash After Viewers Draw Geo Shapes In Multi-User
This commit is contained in:
Anton Georgiev 2024-03-20 14:20:01 -04:00 committed by GitHub
commit ac4899e3be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -859,10 +859,11 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
});
Object.values(updated).forEach(([_, record]) => {
const createdBy = prevShapesRef.current[record?.id]?.meta?.createdBy || currentUser?.userId;
const updatedRecord = {
...record,
meta: {
...prevShapesRef.current[record?.id]?.meta,
createdBy,
updatedBy: currentUser?.userId,
},
};
@ -970,12 +971,14 @@ 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 || isModerator)) return next;
// Filter selectedShapeIds based on shape owner
if (!isEqual(prev.selectedShapeIds, next.selectedShapeIds)) {
if (next.selectedShapeIds.length > 0 && !isEqual(prev.selectedShapeIds, next.selectedShapeIds)) {
next.selectedShapeIds = next.selectedShapeIds.filter(shapeId => {
const shapeOwner = prevShapesRef.current[shapeId]?.meta?.createdBy;
return shapeOwner === currentUser?.userId;
return !shapeOwner || shapeOwner === currentUser?.userId;
});
}