mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-10 11:35:52 +01:00
fix: images not initialized correctly (#4157)
* fix: image not initialized correctly due to not renewing `state.pendingImageElement` * ensure we replace elements on update * set file as errored on >= 400 status respones
This commit is contained in:
parent
8df1a11535
commit
790e6da500
@ -4270,12 +4270,24 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
if (updatedFiles.has(element.fileId)) {
|
if (updatedFiles.has(element.fileId)) {
|
||||||
invalidateShapeForElement(element);
|
invalidateShapeForElement(element);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (erroredFiles.size) {
|
||||||
|
this.scene.replaceAllElements(
|
||||||
|
this.scene.getElementsIncludingDeleted().map((element) => {
|
||||||
|
if (
|
||||||
|
isInitializedImageElement(element) &&
|
||||||
|
erroredFiles.has(element.fileId)
|
||||||
|
) {
|
||||||
|
return newElementWith(element, {
|
||||||
|
status: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (erroredFiles.has(element.fileId)) {
|
|
||||||
newElementWith(element, { status: "error" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { updatedFiles, erroredFiles };
|
return { updatedFiles, erroredFiles };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -294,6 +294,8 @@ export const loadFilesFromFirebase = async (
|
|||||||
dataURL,
|
dataURL,
|
||||||
created: metadata?.created || Date.now(),
|
created: metadata?.created || Date.now(),
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
erroredFiles.set(id, true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
erroredFiles.set(id, true);
|
erroredFiles.set(id, true);
|
||||||
|
@ -460,12 +460,17 @@ const ExcalidrawWrapper = () => {
|
|||||||
if (excalidrawAPI) {
|
if (excalidrawAPI) {
|
||||||
let didChange = false;
|
let didChange = false;
|
||||||
|
|
||||||
|
let pendingImageElement = appState.pendingImageElement;
|
||||||
const elements = excalidrawAPI
|
const elements = excalidrawAPI
|
||||||
.getSceneElementsIncludingDeleted()
|
.getSceneElementsIncludingDeleted()
|
||||||
.map((element) => {
|
.map((element) => {
|
||||||
if (localFileStorage.shouldUpdateImageElementStatus(element)) {
|
if (localFileStorage.shouldUpdateImageElementStatus(element)) {
|
||||||
didChange = true;
|
didChange = true;
|
||||||
return newElementWith(element, { status: "saved" });
|
const newEl = newElementWith(element, { status: "saved" });
|
||||||
|
if (pendingImageElement === element) {
|
||||||
|
pendingImageElement = newEl;
|
||||||
|
}
|
||||||
|
return newEl;
|
||||||
}
|
}
|
||||||
return element;
|
return element;
|
||||||
});
|
});
|
||||||
@ -473,6 +478,9 @@ const ExcalidrawWrapper = () => {
|
|||||||
if (didChange) {
|
if (didChange) {
|
||||||
excalidrawAPI.updateScene({
|
excalidrawAPI.updateScene({
|
||||||
elements,
|
elements,
|
||||||
|
appState: {
|
||||||
|
pendingImageElement,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user