duplicate point on cmd+d (#1831)

This commit is contained in:
David Luzar 2020-07-07 13:53:44 +02:00 committed by GitHub
parent 84abda82d5
commit b1261eea70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 49 deletions

View file

@ -269,51 +269,53 @@ class App extends React.Component<any, AppState> {
);
}
private syncActionResult = withBatchedUpdates((res: ActionResult) => {
if (this.unmounted) {
return;
}
let editingElement: AppState["editingElement"] | null = null;
if (res.elements) {
res.elements.forEach((element) => {
if (
this.state.editingElement?.id === element.id &&
this.state.editingElement !== element &&
isNonDeletedElement(element)
) {
editingElement = element;
}
});
globalSceneState.replaceAllElements(res.elements);
if (res.commitToHistory) {
history.resumeRecording();
private syncActionResult = withBatchedUpdates(
(actionResult: ActionResult) => {
if (this.unmounted || actionResult === false) {
return;
}
}
if (res.appState || editingElement) {
if (res.commitToHistory) {
history.resumeRecording();
}
this.setState(
(state) => ({
...res.appState,
editingElement:
editingElement || res.appState?.editingElement || null,
isCollaborating: state.isCollaborating,
collaborators: state.collaborators,
}),
() => {
if (res.syncHistory) {
history.setCurrentState(
this.state,
globalSceneState.getElementsIncludingDeleted(),
);
let editingElement: AppState["editingElement"] | null = null;
if (actionResult.elements) {
actionResult.elements.forEach((element) => {
if (
this.state.editingElement?.id === element.id &&
this.state.editingElement !== element &&
isNonDeletedElement(element)
) {
editingElement = element;
}
},
);
}
});
});
globalSceneState.replaceAllElements(actionResult.elements);
if (actionResult.commitToHistory) {
history.resumeRecording();
}
}
if (actionResult.appState || editingElement) {
if (actionResult.commitToHistory) {
history.resumeRecording();
}
this.setState(
(state) => ({
...actionResult.appState,
editingElement:
editingElement || actionResult.appState?.editingElement || null,
isCollaborating: state.isCollaborating,
collaborators: state.collaborators,
}),
() => {
if (actionResult.syncHistory) {
history.setCurrentState(
this.state,
globalSceneState.getElementsIncludingDeleted(),
);
}
},
);
}
},
);
// Lifecycle