Merge pull request #16952 from antobinary/wb-fix

fix: avoid wb crash when switching presentation
This commit is contained in:
Ramón Souza 2023-03-08 08:36:59 -03:00 committed by GitHub
commit 2fabb1a8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1023,7 +1023,9 @@ export default function Whiteboard(props) {
const changedShapes = command.after?.document?.pages[app.currentPageId]?.shapes;
if (!isMounting && app.currentPageId !== curPageId) {
// can happen then the "move to page action" is called, or using undo after changing a page
const newWhiteboardId = curPres.pages.find(page => page.num === Number.parseInt(app.currentPageId)).id;
const currentPage = curPres.pages.find(page => page.num === Number.parseInt(app.currentPageId));
if (!currentPage) return;
const newWhiteboardId = currentPage.id;
//remove from previous page and persist on new
changedShapes && removeShapes(Object.keys(changedShapes), whiteboardId);
changedShapes && Object.entries(changedShapes)