fix: clear image/shape cache of affected elements when adding files (#4089)

This commit is contained in:
David Luzar 2021-10-23 14:17:04 +02:00 committed by GitHub
parent 7dbd0c5e0a
commit 5c5b8c517f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1520,19 +1520,23 @@ class App extends React.Component<AppProps, AppState> {
}, new Map<FileId, BinaryFileData>()); }, new Map<FileId, BinaryFileData>());
this.files = { ...this.files, ...Object.fromEntries(filesMap) }; this.files = { ...this.files, ...Object.fromEntries(filesMap) };
this.addNewImagesToImageCache();
// bump versions for elements that reference added files so that // bump versions for elements that reference added files so that
// we/host apps can detect the change // we/host apps can detect the change, and invalidate the image & shape
// cache
this.scene.getElements().forEach((element) => { this.scene.getElements().forEach((element) => {
if ( if (
isInitializedImageElement(element) && isInitializedImageElement(element) &&
filesMap.has(element.fileId) filesMap.has(element.fileId)
) { ) {
this.imageCache.delete(element.fileId);
invalidateShapeForElement(element);
bumpVersion(element); bumpVersion(element);
} }
}); });
this.scene.informMutation(); this.scene.informMutation();
this.addNewImagesToImageCache();
}, },
); );