diff options
Diffstat (limited to 'modern/src/form')
-rw-r--r-- | modern/src/form/LinkField.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modern/src/form/LinkField.js b/modern/src/form/LinkField.js index 26e1471e..81467a1b 100644 --- a/modern/src/form/LinkField.js +++ b/modern/src/form/LinkField.js @@ -44,20 +44,22 @@ const LinkField = ({ const onChange = async (event) => { const oldValue = linked; const newValue = event.target.value; - for (const added of newValue.filter((it) => !oldValue.includes(it))) { - await fetch('/api/permissions', { + const results = []; + newValue.filter((it) => !oldValue.includes(it)).forEach((added) => { + results.push(fetch('/api/permissions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(createBody(added)), - }); - } - for (const removed of oldValue.filter((it) => !newValue.includes(it))) { - await fetch('/api/permissions', { + })); + }); + oldValue.filter((it) => !newValue.includes(it)).forEach((removed) => { + results.push(fetch('/api/permissions', { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(createBody(removed)), - }); - } + })); + }); + await Promise.all(results); setLinked(newValue); }; |