This commit is contained in:
NepNep21 2022-08-27 14:07:23 -03:00
parent b51882a5d8
commit f5b56ee42f
No known key found for this signature in database
GPG Key ID: 818E86B41BD5C364
2 changed files with 19 additions and 8 deletions

View File

@ -46,7 +46,7 @@ import {
TopToolbar,
sanitizeListRestProps,
NumberField,
ImageField
ImageField,
} from "react-admin";
import { Link } from "react-router-dom";
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
@ -451,7 +451,8 @@ export const UserEdit = props => {
perPage={50}
sort={{ field: "created_ts", order: "DESC" }}
>
<Datagrid style={{ width: "100%" }}
<Datagrid
style={{ width: "100%" }}
expand={<ImageField source="url" />}
isRowExpandable={row => row.is_image}
>

View File

@ -27,7 +27,7 @@ const mxcUrlToHttp = mxcUrl => {
async function isImage(url) {
const resp = await fetch(url, {
method: "HEAD"
method: "HEAD",
});
const type = resp.headers.get("Content-Type");
@ -170,8 +170,18 @@ const resourceMap = {
map: async um => ({
...um,
id: um.media_id,
url: `${localStorage.getItem("base_url")}/_matrix/media/v3/download/${localStorage.getItem("home_server")}/${um.media_id}`,
is_image: await isImage(`${localStorage.getItem("base_url")}/_matrix/media/v3/download/${localStorage.getItem("home_server")}/${um.media_id}`)
url: `${localStorage.getItem(
"base_url"
)}/_matrix/media/v3/download/${localStorage.getItem("home_server")}/${
um.media_id
}`,
is_image: await isImage(
`${localStorage.getItem(
"base_url"
)}/_matrix/media/v3/download/${localStorage.getItem("home_server")}/${
um.media_id
}`
),
}),
reference: id => ({
endpoint: `/_synapse/admin/v1/users/${id}/media`,
@ -416,7 +426,7 @@ const dataProvider = {
return {
data: data,
total: res.total(json, from, perPage),
}
};
});
},