fix(striker-ui): let fetch refresh handle remove peers after delete

main
Tsu-ba-me 2 years ago
parent eddb0ea393
commit f2cf39a0dc
  1. 22
      striker-ui/components/StrikerConfig/ConfigPeersForm.tsx

@ -163,25 +163,16 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
listItems={peerConnections}
onDelete={() => {
const pairs = Object.entries(peerConnections);
const {
body: deleteRequestBody,
post: remainingPeerConnections,
} = pairs.reduce<{
body: APIDeleteHostConnectionRequestBody;
post: PeerConnectionList;
}>(
(previous, [key, value]) => {
const { hostUUID, isChecked } = value;
const deleteRequestBody =
pairs.reduce<APIDeleteHostConnectionRequestBody>(
(previous, [, { hostUUID, isChecked }]) => {
if (isChecked) {
previous.body.local.push(hostUUID);
} else {
previous.post[key] = value;
previous.local.push(hostUUID);
}
return previous;
},
{ body: { local: [] }, post: {} },
{ local: [] },
);
const deleteCount = deleteRequestBody.local.length;
@ -192,9 +183,6 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
onProceedAppend: () => {
api
.delete('/host/connection', { data: deleteRequestBody })
.then(() => {
setPeerConnections(remainingPeerConnections);
})
.catch((error) => {
const emsg = handleAPIError(error);

Loading…
Cancel
Save