|
@@ -1458,26 +1458,30 @@ class App extends React.Component<AppProps, AppState> {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- public updateScene = withBatchedUpdates((sceneData: SceneData) => {
|
|
|
|
- if (sceneData.commitToHistory) {
|
|
|
|
- this.history.resumeRecording();
|
|
|
|
- }
|
|
|
|
|
|
+ public updateScene = withBatchedUpdates(
|
|
|
|
+ <K extends keyof AppState>(sceneData: {
|
|
|
|
+ elements?: SceneData["elements"];
|
|
|
|
+ appState?: Pick<AppState, K> | null;
|
|
|
|
+ collaborators?: SceneData["collaborators"];
|
|
|
|
+ commitToHistory?: SceneData["commitToHistory"];
|
|
|
|
+ }) => {
|
|
|
|
+ if (sceneData.commitToHistory) {
|
|
|
|
+ this.history.resumeRecording();
|
|
|
|
+ }
|
|
|
|
|
|
- // currently we only support syncing background color
|
|
|
|
- if (sceneData.appState?.viewBackgroundColor) {
|
|
|
|
- this.setState({
|
|
|
|
- viewBackgroundColor: sceneData.appState.viewBackgroundColor,
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ if (sceneData.appState) {
|
|
|
|
+ this.setState(sceneData.appState);
|
|
|
|
+ }
|
|
|
|
|
|
- if (sceneData.elements) {
|
|
|
|
- this.scene.replaceAllElements(sceneData.elements);
|
|
|
|
- }
|
|
|
|
|
|
+ if (sceneData.elements) {
|
|
|
|
+ this.scene.replaceAllElements(sceneData.elements);
|
|
|
|
+ }
|
|
|
|
|
|
- if (sceneData.collaborators) {
|
|
|
|
- this.setState({ collaborators: sceneData.collaborators });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ if (sceneData.collaborators) {
|
|
|
|
+ this.setState({ collaborators: sceneData.collaborators });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
|
|
private onSceneUpdated = () => {
|
|
private onSceneUpdated = () => {
|
|
this.setState({});
|
|
this.setState({});
|