web/timeline: prefer encrypted url if set

This commit is contained in:
Tulir Asokan 2024-10-23 16:02:20 +03:00
parent 508f2252da
commit cc4eb16c7c

View file

@ -23,9 +23,9 @@ import DownloadIcon from "@/icons/download.svg?react"
export const useMediaContent = ( export const useMediaContent = (
content: MediaMessageEventContent, evtType: EventType, containerSize?: ImageContainerSize, content: MediaMessageEventContent, evtType: EventType, containerSize?: ImageContainerSize,
): [React.ReactElement | null, string, CSSProperties] => { ): [React.ReactElement | null, string, CSSProperties] => {
const mediaURL = content.url ? getMediaURL(content.url) : getEncryptedMediaURL(content.file?.url) const mediaURL = content.file?.url ? getEncryptedMediaURL(content.file.url) : getMediaURL(content.url)
const thumbnailURL = content.info?.thumbnail_url const thumbnailURL = content.info?.thumbnail_file?.url
? getMediaURL(content.info.thumbnail_url) : getEncryptedMediaURL(content.info?.thumbnail_file?.url) ? getEncryptedMediaURL(content.info.thumbnail_file.url) : getMediaURL(content.info?.thumbnail_url)
if (content.msgtype === "m.image" || evtType === "m.sticker") { if (content.msgtype === "m.image" || evtType === "m.sticker") {
const style = calculateMediaSize(content.info?.w, content.info?.h, containerSize) const style = calculateMediaSize(content.info?.w, content.info?.h, containerSize)
return [<img return [<img