Skip to content

Commit 09e4454

Browse files
committed
fix(thumbnail): fallback doesn't work in encrypt room
1 parent 3dc08ab commit 09e4454

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/app/components/message/content/ImageContent.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ export const ImageContent = as<'div', ImageContentProps>(
9696
useCallback(async () => {
9797
const mediaUrl = (useThumbnail ? mxcUrlToHttp(mx, url, useAuthentication, imgWidth, imgHeight, resizeMethod) : mxcUrlToHttp(mx, url, useAuthentication)) ?? url;
9898
if (encInfo) {
99-
const fileContent = await downloadEncryptedMedia(mediaUrl, (encBuf) =>
100-
decryptFile(encBuf, mimeType ?? FALLBACK_MIMETYPE, encInfo)
101-
);
99+
const decrypt = (encBuf: ArrayBuffer) => decryptFile(encBuf, mimeType ?? FALLBACK_MIMETYPE, encInfo);
100+
let fileContent;
101+
try {
102+
fileContent = await downloadEncryptedMedia(mediaUrl, decrypt);
103+
} catch {
104+
fileContent = await downloadEncryptedMedia(mxcUrlToHttp(mx, url, useAuthentication) ?? url, decrypt);
105+
}
102106
return URL.createObjectURL(fileContent);
103107
}
104108
return mediaUrl;

0 commit comments

Comments
 (0)