Merge pull request #19733 from KDSBrowne/v30-update-while-selected
fix(whiteboard): Selected Shapes Fail To Update On External Edits
This commit is contained in:
commit
4e8cff0678
@ -158,6 +158,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
const whiteboardIdRef = React.useRef(whiteboardId);
|
const whiteboardIdRef = React.useRef(whiteboardId);
|
||||||
const curPageIdRef = React.useRef(curPageId);
|
const curPageIdRef = React.useRef(curPageId);
|
||||||
const hasWBAccessRef = React.useRef(hasWBAccess);
|
const hasWBAccessRef = React.useRef(hasWBAccess);
|
||||||
|
const isModeratorRef = React.useRef(isModerator);
|
||||||
|
|
||||||
const THRESHOLD = 0.1;
|
const THRESHOLD = 0.1;
|
||||||
const lastKnownHeight = React.useRef(presentationAreaHeight);
|
const lastKnownHeight = React.useRef(presentationAreaHeight);
|
||||||
@ -169,6 +170,10 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
curPageIdRef.current = curPageId;
|
curPageIdRef.current = curPageId;
|
||||||
}, [curPageId]);
|
}, [curPageId]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
isModeratorRef.current = isModerator;
|
||||||
|
}, [isModerator]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
whiteboardIdRef.current = whiteboardId;
|
whiteboardIdRef.current = whiteboardId;
|
||||||
}, [whiteboardId]);
|
}, [whiteboardId]);
|
||||||
@ -268,7 +273,11 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
typeName: remoteShape.typeName,
|
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) => {
|
Object.keys(remoteShape).forEach((key) => {
|
||||||
if (key !== "isModerator" && !isEqual(remoteShape[key], localShape[key])) {
|
if (key !== "isModerator" && !isEqual(remoteShape[key], localShape[key])) {
|
||||||
diff[key] = remoteShape[key];
|
diff[key] = remoteShape[key];
|
||||||
@ -855,7 +864,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
createdBy: currentUser?.userId,
|
createdBy: currentUser?.userId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModerator);
|
persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModeratorRef.current);
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.values(updated).forEach(([_, record]) => {
|
Object.values(updated).forEach(([_, record]) => {
|
||||||
@ -867,7 +876,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
updatedBy: currentUser?.userId,
|
updatedBy: currentUser?.userId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModerator);
|
persistShapeWrapper(updatedRecord, whiteboardIdRef.current, isModeratorRef.current);
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.values(removed).forEach((record) => {
|
Object.values(removed).forEach((record) => {
|
||||||
@ -972,7 +981,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
editor.store.onBeforeChange = (prev, next, source) => {
|
editor.store.onBeforeChange = (prev, next, source) => {
|
||||||
if (next?.typeName === "instance_page_state") {
|
if (next?.typeName === "instance_page_state") {
|
||||||
|
|
||||||
if ((isPresenter || isModerator)) return next;
|
if (isPresenter || isModeratorRef.current) return next;
|
||||||
|
|
||||||
// Filter selectedShapeIds based on shape owner
|
// Filter selectedShapeIds based on shape owner
|
||||||
if (next.selectedShapeIds.length > 0 && !isEqual(prev.selectedShapeIds, next.selectedShapeIds)) {
|
if (next.selectedShapeIds.length > 0 && !isEqual(prev.selectedShapeIds, next.selectedShapeIds)) {
|
||||||
@ -1033,7 +1042,7 @@ export default Whiteboard = React.memo(function Whiteboard(props) {
|
|||||||
<div
|
<div
|
||||||
ref={whiteboardRef}
|
ref={whiteboardRef}
|
||||||
id={"whiteboard-element"}
|
id={"whiteboard-element"}
|
||||||
key={`animations=-${animations}-${isPresenter}-${isModerator}-${whiteboardToolbarAutoHide}-${language}`}
|
key={`animations=-${animations}-${whiteboardToolbarAutoHide}-${language}`}
|
||||||
>
|
>
|
||||||
<Tldraw
|
<Tldraw
|
||||||
key={`tldrawv2-${presentationId}-${animations}`}
|
key={`tldrawv2-${presentationId}-${animations}`}
|
||||||
|
Loading…
Reference in New Issue
Block a user