From 5c5b8c517f19fe2f8227a4d88e590aa007385336 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sat, 23 Oct 2021 14:17:04 +0200 Subject: [PATCH] fix: clear image/shape cache of affected elements when adding files (#4089) --- src/components/App.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 858de118..0ff5c18d 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1520,19 +1520,23 @@ class App extends React.Component { }, new Map()); this.files = { ...this.files, ...Object.fromEntries(filesMap) }; - this.addNewImagesToImageCache(); // 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) => { if ( isInitializedImageElement(element) && filesMap.has(element.fileId) ) { + this.imageCache.delete(element.fileId); + invalidateShapeForElement(element); bumpVersion(element); } }); this.scene.informMutation(); + + this.addNewImagesToImageCache(); }, );