Skip to content

Commit

Permalink
prevent whiteboard crash after drawing shapes in multi-user
Browse files Browse the repository at this point in the history
  • Loading branch information
KDSBrowne committed Feb 24, 2024
1 parent ff58fa0 commit f8ea19a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,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,
},
};
Expand Down Expand Up @@ -915,12 +916,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;
});
}

Expand Down

0 comments on commit f8ea19a

Please sign in to comment.