Use new API of dataProvider

Change-Id: I2789f1f1384b48e876bee5af421ff5db66fa3416
This commit is contained in:
dklimpel 2024-02-06 11:23:38 +01:00 committed by Manuel Stahl
parent 76ef017244
commit 3adc6b4663
3 changed files with 15 additions and 13 deletions

View file

@ -27,7 +27,8 @@ export const DeviceRemoveButton = props => {
const handleConfirm = () => {
removeDevice(
"devices",
{ id: record.id, meta: { user_id: record.user_id } },
// needs previousData for user_id
{ id: record.id, previousData: record },
{
onSuccess: () => {
notify("resources.devices.action.erase.success");

View file

@ -93,17 +93,18 @@ export const DeleteMediaButton = props => {
const notify = useNotify();
const [deleteOne, { isLoading }] = useDelete();
const handleDialogOpen = () => setOpen(true);
const handleDialogClose = () => setOpen(false);
const openDialog = () => setOpen(true);
const closeDialog = () => setOpen(false);
const handleSend = values => {
const deleteMedia = values => {
deleteOne(
"delete_media",
{ id: values.id },
// needs meta.before_ts, meta.size_gt and meta.keep_profiles
{ meta: values },
{
onSuccess: () => {
notify("resources.delete_media.action.send_success");
handleDialogClose();
closeDialog();
},
onError: () =>
notify("resources.delete_media.action.send_failure", {
@ -118,7 +119,7 @@ export const DeleteMediaButton = props => {
<Button
{...props}
label="resources.delete_media.action.send"
onClick={handleDialogOpen}
onClick={openDialog}
disabled={isLoading}
sx={{
color: theme.palette.error.main,
@ -135,14 +136,14 @@ export const DeleteMediaButton = props => {
</Button>
<DeleteMediaDialog
open={open}
onClose={handleDialogClose}
onSend={handleSend}
onClose={closeDialog}
onSubmit={deleteMedia}
/>
</>
);
};
export const ProtectMediaButton = props => {
export const ProtectMediaButton = () => {
const record = useRecordContext();
const translate = useTranslate();
const refresh = useRefresh();
@ -270,7 +271,7 @@ export const QuarantineMediaButton = props => {
const handleRemoveQuarantaine = () => {
deleteOne(
"quarantine_media",
{ id: record.id },
{ id: record.id, previousData: record },
{
onSuccess: () => {
notify("resources.quarantine_media.action.send_success");

View file

@ -98,7 +98,7 @@ const resourceMap = {
}),
delete: params => ({
endpoint: `/_synapse/admin/v2/users/${encodeURIComponent(
params.meta.user_id
params.previousData.user_id
)}/devices/${params.id}`,
}),
},
@ -546,7 +546,7 @@ const dataProvider = {
const endpoint_url = homeserver + res.path;
return jsonClient(`${endpoint_url}/${params.id}`, {
method: "DELETE",
body: JSON.stringify(params.data, filterNullValues),
body: JSON.stringify(params.previousData, filterNullValues),
}).then(({ json }) => ({
data: json,
}));