소스 검색

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

David Luzar 3 년 전
부모
커밋
5c5b8c517f
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      src/components/App.tsx

+ 6 - 2
src/components/App.tsx

@@ -1520,19 +1520,23 @@ class App extends React.Component<AppProps, AppState> {
       }, new Map<FileId, BinaryFileData>());
 
       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();
     },
   );