From 3adc6b4663ec741176389f6ecb70112bc7d058e3 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:23:38 +0100 Subject: [PATCH] Use new API of dataProvider Change-Id: I2789f1f1384b48e876bee5af421ff5db66fa3416 --- src/components/devices.js | 3 ++- src/components/media.js | 21 +++++++++++---------- src/synapse/dataProvider.js | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/devices.js b/src/components/devices.js index c81a005..7a5069a 100644 --- a/src/components/devices.js +++ b/src/components/devices.js @@ -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"); diff --git a/src/components/media.js b/src/components/media.js index fec66a6..cc06a0b 100644 --- a/src/components/media.js +++ b/src/components/media.js @@ -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 => { ); }; -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"); diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 39e099a..acdc6a1 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -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, }));