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

View File

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