diff --git a/src/renderer/src/components/editor/ImageViewer.tsx b/src/renderer/src/components/editor/ImageViewer.tsx index 5e97c85fe7a..fafa68b1ab1 100644 --- a/src/renderer/src/components/editor/ImageViewer.tsx +++ b/src/renderer/src/components/editor/ImageViewer.tsx @@ -65,7 +65,12 @@ export default function ImageViewer({ const filename = useMemo(() => filePath.split(/[/\\]/).pop() || filePath, [filePath]) const cleanedContent = useMemo(() => content.replace(/\s/g, ''), [content]) // A remint changes only the URL's revision; keep zoom unless the grant or the file's size changed. - const imageStateKey = `${filePath}\n${mimeType}\n${src ? `${src.split('?')[0]}\n${byteSize ?? ''}` : cleanedContent}` + const srcIdentity = src ? src.split('?')[0] : undefined + const imageStateKey = useMemo( + () => + `${filePath}\n${mimeType}\n${srcIdentity !== undefined ? `${srcIdentity}\n${byteSize ?? ''}` : cleanedContent}`, + [filePath, mimeType, srcIdentity, byteSize, cleanedContent] + ) const [lastImageStateKey, setLastImageStateKey] = useState(imageStateKey) if (lastImageStateKey !== imageStateKey) { setLastImageStateKey(imageStateKey)