Fix three rendering when loading (#986)

The problem is that syncActionResult wasn't using batching.
This commit is contained in:
Christopher Chedeau 2020-03-16 19:21:01 -07:00 committed by GitHub
parent e9f5175f51
commit 0dc07135b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,31 +186,30 @@ export class App extends React.Component<any, AppState> {
this.actionManager.registerAction(createRedoAction(history)); this.actionManager.registerAction(createRedoAction(history));
} }
private syncActionResult = ( private syncActionResult = withBatchedUpdates(
res: ActionResult, (res: ActionResult, commitToHistory: boolean = true) => {
commitToHistory: boolean = true, if (this.unmounted) {
) => { return;
if (this.unmounted) { }
return; if (res.elements) {
} globalSceneState.replaceAllElements(res.elements);
if (res.elements) { if (commitToHistory) {
globalSceneState.replaceAllElements(res.elements); history.resumeRecording();
if (commitToHistory) { }
history.resumeRecording();
} }
}
if (res.appState) { if (res.appState) {
if (commitToHistory) { if (commitToHistory) {
history.resumeRecording(); history.resumeRecording();
}
this.setState(state => ({
...res.appState,
isCollaborating: state.isCollaborating,
collaborators: state.collaborators,
}));
} }
this.setState(state => ({ },
...res.appState, );
isCollaborating: state.isCollaborating,
collaborators: state.collaborators,
}));
}
};
private onCut = withBatchedUpdates((event: ClipboardEvent) => { private onCut = withBatchedUpdates((event: ClipboardEvent) => {
if (isWritableElement(event.target)) { if (isWritableElement(event.target)) {