diff --git a/src/app/components/message/content/AudioContent.tsx b/src/app/components/message/content/AudioContent.tsx index b426654f..d6a82a3b 100644 --- a/src/app/components/message/content/AudioContent.tsx +++ b/src/app/components/message/content/AudioContent.tsx @@ -50,7 +50,7 @@ export function AudioContent({ const [srcState, loadSrc] = useAsyncCallback( useCallback( - () => getFileSrcUrl(mxcUrlToHttp(mx, url, useAuthentication) ?? '', mimeType, encInfo), + () => getFileSrcUrl(mxcUrlToHttp(mx, url, useAuthentication) ?? '', mimeType, encInfo, true), [mx, url, useAuthentication, mimeType, encInfo] ) ); diff --git a/src/app/components/message/content/VideoContent.tsx b/src/app/components/message/content/VideoContent.tsx index 46f82fae..1683075b 100644 --- a/src/app/components/message/content/VideoContent.tsx +++ b/src/app/components/message/content/VideoContent.tsx @@ -71,7 +71,7 @@ export const VideoContent = as<'div', VideoContentProps>( const [srcState, loadSrc] = useAsyncCallback( useCallback( - () => getFileSrcUrl(mxcUrlToHttp(mx, url, useAuthentication) ?? '', mimeType, encInfo), + () => getFileSrcUrl(mxcUrlToHttp(mx, url, useAuthentication) ?? '', mimeType, encInfo, true), [mx, url, useAuthentication, mimeType, encInfo] ) ); diff --git a/src/app/components/message/content/util.ts b/src/app/components/message/content/util.ts index 2cc43418..8614b8ec 100644 --- a/src/app/components/message/content/util.ts +++ b/src/app/components/message/content/util.ts @@ -4,7 +4,8 @@ import { decryptFile } from '../../../utils/matrix'; export const getFileSrcUrl = async ( httpUrl: string, mimeType: string, - encInfo?: EncryptedAttachmentInfo + encInfo?: EncryptedAttachmentInfo, + forceFetch?: boolean ): Promise => { if (encInfo) { if (typeof httpUrl !== 'string') throw new Error('Malformed event'); @@ -13,6 +14,12 @@ export const getFileSrcUrl = async ( const decryptedBlob = await decryptFile(encData, mimeType, encInfo); return URL.createObjectURL(decryptedBlob); } + if (forceFetch) { + const res = await fetch(httpUrl, { method: 'GET' }); + const blob = await res.blob(); + return URL.createObjectURL(blob); + } + return httpUrl; };