Compare commits

..

No commits in common. "avatar" and "master" have entirely different histories.

2 changed files with 6 additions and 38 deletions

View file

@ -36,8 +36,6 @@ import {
ExportButton,
TopToolbar,
sanitizeListRestProps,
ImageInput,
ImageField,
} from "react-admin";
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
import { DeviceRemoveButton } from "./devices";
@ -223,9 +221,6 @@ export const UserEdit = props => {
<TextInput source="id" disabled />
<TextInput source="displayname" />
<PasswordInput source="password" autoComplete="new-password" />
<ImageInput source="avatar_file" label="Avatar" accept="image/*">
<ImageField source="avatar_src" title="Avatar" />
</ImageInput>
<BooleanInput source="admin" />
<BooleanInput
source="deactivated"

View file

@ -32,7 +32,6 @@ const resourceMap = {
...u,
id: u.name,
avatar_src: mxcUrlToHttp(u.avatar_url),
avatar_url: u.avatar_url,
is_guest: !!u.is_guest,
admin: !!u.admin,
deactivated: !!u.deactivated,
@ -203,38 +202,12 @@ const dataProvider = {
const res = resourceMap[resource];
const endpoint_url = homeserver + res.path;
// In case there is a avatar_file object, save it in the media repository
// and update the avatar_url.
const f = params?.data?.avatar_file?.rawFile;
if (f instanceof File) {
const file_endpoint =
homeserver + "/_matrix/media/r0/upload?filename=" + f.name;
const headers = new Headers();
headers.append("Content-Type", f.type);
const options = {
method: "POST",
body: f,
headers: headers,
};
return jsonClient(file_endpoint, options).then(r => {
params.data.avatar_url = r.json.content_uri;
return jsonClient(`${endpoint_url}/${params.data.id}`, {
method: "PUT",
body: JSON.stringify(params.data, filterNullValues),
}).then(({ json }) => ({
data: res.map(json),
}));
});
} else {
return jsonClient(`${endpoint_url}/${params.data.id}`, {
method: "PUT",
body: JSON.stringify(params.data, filterNullValues),
}).then(({ json }) => ({
data: res.map(json),
}));
}
return jsonClient(`${endpoint_url}/${params.data.id}`, {
method: "PUT",
body: JSON.stringify(params.data, filterNullValues),
}).then(({ json }) => ({
data: res.map(json),
}));
},
updateMany: (resource, params) => {