admin/accounts: better code, don't mess with immutables

Massimo Melina committed Nov 1, 2025 at 17:01 UTC b33bc7853e2574caa6ce7f9f2f812d59a00b8dcf
1 file changed +7 -5
admin/src/AccountsPage.ts
+7 -5
@@ -169,12 +169,14 @@ export default function AccountsPage() {
169 }
170
171 async function deleteAccounts() {
172 - if (sel.length > _.pull(sel, username).length)
173 - if (!await confirmDialog(`Will delete the rest but not current account (${username})`)) return
174 - if (!sel.length) return
175 - if (!await confirmDialog(`Delete ${sel.length} item(s)?`)) return
172 + const toDelete = _.without(sel, username)
173 + if (sel.length > toDelete.length)
174 + if (!await confirmDialog(`You cannot ask to delete the account you are using. Continue with the rest?`)) return
175 + if (!toDelete.length)
176 + return alertDialog("Nothing to delete", 'info')
177 + if (!await confirmDialog(`Delete ${toDelete.length} item(s)?`)) return
178 const errors = []
177 - for (const username of sel)
179 + for (const username of toDelete)
180 if (!await apiCall('del_account', { username }).then(() => 1, () => 0))
181 errors.push(username)
182 reload()