mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Race condiition fixed for fix:9104
This commit is contained in:
parent
74b8f7ee26
commit
1053a51f64
2 changed files with 17 additions and 6 deletions
|
@ -165,9 +165,7 @@ const ActiveRoomDialog = ({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
trackEvent("share", "room closed");
|
trackEvent("share", "room closed");
|
||||||
collabAPI.stopCollaboration().then(() => {
|
collabAPI.stopCollaboration().then(() => {
|
||||||
if (!collabAPI.isCollaborating()) {
|
|
||||||
handleClose();
|
handleClose();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -2250,7 +2250,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
this.setState((state) => ({
|
this.setState((state) => ({
|
||||||
...getDefaultAppState(),
|
...getDefaultAppState(),
|
||||||
isLoading: opts?.resetLoadingState ? false : state.isLoading,
|
isLoading: opts?.resetLoadingState ? false : state.isLoading,
|
||||||
theme: this.state.theme,
|
theme: state.theme,
|
||||||
}));
|
}));
|
||||||
this.resetStore();
|
this.resetStore();
|
||||||
this.resetHistory();
|
this.resetHistory();
|
||||||
|
@ -2874,10 +2874,23 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
// init, which would trigger onChange with empty elements, which would then
|
// init, which would trigger onChange with empty elements, which would then
|
||||||
// override whatever is in localStorage currently.
|
// override whatever is in localStorage currently.
|
||||||
if (!this.state.isLoading) {
|
if (!this.state.isLoading) {
|
||||||
|
// Only trigger onChange when there are actual changes to elements or important app state
|
||||||
|
const prevElements = this.scene.getElementsIncludingDeleted();
|
||||||
|
const hasElementChanges = elements.length !== prevElements.length ||
|
||||||
|
elements.some((element, index) => element !== prevElements[index]);
|
||||||
|
|
||||||
|
const hasImportantStateChanges =
|
||||||
|
this.state.selectedElementIds !== prevState.selectedElementIds ||
|
||||||
|
this.state.width !== prevState.width ||
|
||||||
|
this.state.height !== prevState.height ||
|
||||||
|
this.state.editingTextElement !== prevState.editingTextElement;
|
||||||
|
|
||||||
|
if (hasElementChanges || hasImportantStateChanges) {
|
||||||
this.props.onChange?.(elements, this.state, this.files);
|
this.props.onChange?.(elements, this.state, this.files);
|
||||||
this.onChangeEmitter.trigger(elements, this.state, this.files);
|
this.onChangeEmitter.trigger(elements, this.state, this.files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private renderInteractiveSceneCallback = ({
|
private renderInteractiveSceneCallback = ({
|
||||||
atLeastOneVisibleElement,
|
atLeastOneVisibleElement,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue