Skip to content

Commit 868f811

Browse files
committed
fix(mobile): keep image size across URL refreshes
1 parent 89c3c1b commit 868f811

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function MessageAttachmentImage(props: {
199199

200200
function ThreadMarkdownImageView(props: {
201201
readonly uri: string | null;
202+
readonly sourceKey: string;
202203
readonly unavailable: boolean;
203204
readonly alt: string | null;
204205
readonly onPressImage: (uri: string) => void;
@@ -210,6 +211,9 @@ function ThreadMarkdownImageView(props: {
210211

211212
useEffect(() => {
212213
setSourceSize(null);
214+
}, [props.sourceKey]);
215+
216+
useEffect(() => {
213217
setFailedUri(null);
214218
}, [props.uri]);
215219

@@ -310,6 +314,7 @@ function ThreadMarkdownImage(props: {
310314
return (
311315
<ThreadMarkdownImageView
312316
uri={assetUrl._tag === "Success" ? assetUrl.url : null}
317+
sourceKey={props.path}
313318
unavailable={assetUrl._tag === "Failure"}
314319
alt={props.alt}
315320
onPressImage={props.onPressImage}
@@ -321,6 +326,7 @@ function ThreadMarkdownImageUnavailable(props: { readonly alt: string | null })
321326
return (
322327
<ThreadMarkdownImageView
323328
uri={null}
329+
sourceKey="unavailable"
324330
unavailable
325331
alt={props.alt}
326332
onPressImage={() => undefined}
@@ -1573,6 +1579,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
15731579
return (
15741580
<ThreadMarkdownImageView
15751581
uri={imageSource.uri}
1582+
sourceKey={imageSource.uri}
15761583
unavailable={false}
15771584
alt={image.alt}
15781585
onPressImage={(uri) => setExpandedImage({ uri })}

0 commit comments

Comments
 (0)