From: Chris Duncan Date: Sat, 26 Oct 2024 07:19:42 +0000 (-0700) Subject: Fix account duplication on select. Fix account select not being reset on wallet change. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=6a1797c9b62b4d9388b58e6921567297cc5127d3;p=nemo-wallet.git Fix account duplication on select. Fix account select not being reset on wallet change. --- diff --git a/app/pages/nemo-wallet.html b/app/pages/nemo-wallet.html index 2e86cd6..d0fdec4 100644 --- a/app/pages/nemo-wallet.html +++ b/app/pages/nemo-wallet.html @@ -202,6 +202,7 @@ default: { try { await reloadAccountSelect() + document.getElementById('account').value = '' } catch (err) { walletSelect.value = '' console.error(err) @@ -295,8 +296,8 @@ } async function selectAccount () { - const accountSelect = document.querySelector('#account') - const walletId = document.querySelector('#wallet')?.value + const accountSelect = document.getElementById('account') + const walletId = document.getElementById('wallet')?.value if (walletId == null || walletId === '') { accountSelect.value = '' accountSelect.setAttribute('disabled', '') @@ -305,7 +306,7 @@ accountSelect.removeAttribute('disabled') if (accountSelect.value === '_new') { try { - return await document.querySelector('#account-new').showModal() + return await document.getElementById('account-new').showModal() } catch (err) { accountSelect.value = '' console.error(err) @@ -340,12 +341,12 @@ if (!select) { throw new TypeError(`Select ${id} not found`) } - const oldOptions = [select.children].filter(o => o.tagName === 'option') - for (const oldOption of oldOptions) { - if (oldOption.value.substring(0, 1) === '_') { - oldOption.remove() - } - } + ([...select.children]) + .filter(o => o.tagName.toLowerCase() === 'option') + .filter(o => typeof o.value === 'string') + .filter(o => o.value.length > 0) + .filter(o => o.value.substring(0, 1) !== '_') + .map(o => o.remove()) options.map(o => select.add(new Option(o.text, o.value))) } catch (err) { console.error(err)