fix: stale appState.pendingImageElement (#5322)

* fix: stale `appState.pendingImageElement`

* unrelated fix for devTools race conditions

* snap fix
This commit is contained in:
David Luzar 2022-06-19 14:13:43 +02:00 committed by GitHub
parent fd48c2cf79
commit 4712393b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 107 additions and 103 deletions

View file

@ -479,19 +479,17 @@ const ExcalidrawWrapper = () => {
if (excalidrawAPI) {
let didChange = false;
let pendingImageElement = appState.pendingImageElement;
const elements = excalidrawAPI
.getSceneElementsIncludingDeleted()
.map((element) => {
if (
LocalData.fileStorage.shouldUpdateImageElementStatus(element)
) {
didChange = true;
const newEl = newElementWith(element, { status: "saved" });
if (pendingImageElement === element) {
pendingImageElement = newEl;
const newElement = newElementWith(element, { status: "saved" });
if (newElement !== element) {
didChange = true;
}
return newEl;
return newElement;
}
return element;
});
@ -499,9 +497,6 @@ const ExcalidrawWrapper = () => {
if (didChange) {
excalidrawAPI.updateScene({
elements,
appState: {
pendingImageElement,
},
});
}
}