fix(thumbnail): fallback doesn't work in encrypt room

This commit is contained in:
纳西妲 · Nahida 2025-08-17 16:40:14 +08:00
parent 3dc08abfed
commit 09e445453c

View file

@ -96,9 +96,13 @@ export const ImageContent = as<'div', ImageContentProps>(
useCallback(async () => { useCallback(async () => {
const mediaUrl = (useThumbnail ? mxcUrlToHttp(mx, url, useAuthentication, imgWidth, imgHeight, resizeMethod) : mxcUrlToHttp(mx, url, useAuthentication)) ?? url; const mediaUrl = (useThumbnail ? mxcUrlToHttp(mx, url, useAuthentication, imgWidth, imgHeight, resizeMethod) : mxcUrlToHttp(mx, url, useAuthentication)) ?? url;
if (encInfo) { if (encInfo) {
const fileContent = await downloadEncryptedMedia(mediaUrl, (encBuf) => const decrypt = (encBuf: ArrayBuffer) => decryptFile(encBuf, mimeType ?? FALLBACK_MIMETYPE, encInfo);
decryptFile(encBuf, mimeType ?? FALLBACK_MIMETYPE, encInfo) let fileContent;
); try {
fileContent = await downloadEncryptedMedia(mediaUrl, decrypt);
} catch {
fileContent = await downloadEncryptedMedia(mxcUrlToHttp(mx, url, useAuthentication) ?? url, decrypt);
}
return URL.createObjectURL(fileContent); return URL.createObjectURL(fileContent);
} }
return mediaUrl; return mediaUrl;