ensure preview works for images only (for now)

This commit is contained in:
Aine 2024-10-03 01:18:45 +03:00
parent 9062a6afb1
commit a15dad4a31
No known key found for this signature in database
GPG key ID: 34969C908CCA2804

View file

@ -314,7 +314,16 @@ export const QuarantineMediaButton = (props: ButtonProps) => {
); );
}; };
export const ViewMediaButton = ({ mxcURL, label }) => { export const ViewMediaButton = ({ mxcURL, label, mimetype }) => {
if (!mimetype.startsWith("image/")) {
return (
<>
<Box style={{ whiteSpace: "pre" }}>
{label}
</Box>
</>
);
}
const translate = useTranslate(); const translate = useTranslate();
const openFileInNewTab = (blobURL: string) => { const openFileInNewTab = (blobURL: string) => {
@ -367,7 +376,7 @@ export const MediaIDField = ({ source }) => {
const mxcURL = `mxc://${homeserver}/${mediaID}`; const mxcURL = `mxc://${homeserver}/${mediaID}`;
return <ViewMediaButton mxcURL={mxcURL} label={mediaID} />; return <ViewMediaButton mxcURL={mxcURL} label={mediaID} mimetype={record.media_type}/>;
}; };
export const ReportMediaContent = ({ source }) => { export const ReportMediaContent = ({ source }) => {
@ -381,5 +390,5 @@ export const ReportMediaContent = ({ source }) => {
return null; return null;
} }
return <ViewMediaButton mxcURL={mxcURL} label={mxcURL} />; return <ViewMediaButton mxcURL={mxcURL} label={mxcURL} mimetype={record.media_type}/>;
}; };