mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix history initialization (#2115)
This commit is contained in:
parent
9cac7816cc
commit
aaddde5dd9
9 changed files with 1052 additions and 48 deletions
|
@ -556,7 +556,11 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
),
|
||||
};
|
||||
}
|
||||
this.syncActionResult(scene);
|
||||
history.clear();
|
||||
this.syncActionResult({
|
||||
...scene,
|
||||
commitToHistory: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1163,11 +1167,12 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
|
||||
const updateScene = (
|
||||
decryptedData: SocketUpdateDataSource[SCENE.INIT | SCENE.UPDATE],
|
||||
{ scrollToContent = false }: { scrollToContent?: boolean } = {},
|
||||
{ init = false }: { init?: boolean } = {},
|
||||
) => {
|
||||
const { elements: remoteElements } = decryptedData.payload;
|
||||
|
||||
if (scrollToContent) {
|
||||
if (init) {
|
||||
history.resumeRecording();
|
||||
this.setState({
|
||||
...this.state,
|
||||
...calculateScrollCenter(
|
||||
|
@ -1292,7 +1297,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
return;
|
||||
case SCENE.INIT: {
|
||||
if (!this.portal.socketInitialized) {
|
||||
updateScene(decryptedData, { scrollToContent: true });
|
||||
updateScene(decryptedData, { init: true });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3626,7 +3631,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
...(appState || this.state),
|
||||
isLoading: false,
|
||||
},
|
||||
commitToHistory: false,
|
||||
commitToHistory: true,
|
||||
}),
|
||||
)
|
||||
.catch((error) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue