fix: scanAddressesWithAmount

This commit is contained in:
Vlad Stan 2022-07-26 13:26:18 +03:00
parent dc2ecfe9a2
commit b576ef4f21
3 changed files with 16 additions and 6 deletions

View file

@ -102,22 +102,22 @@ async function utxoList(path) {
return total return total
}, },
applyUtxoSelectionMode: function () { applyUtxoSelectionMode: function () {
const mode = this.utxoSelectionMode
const isSelectAll = mode === 'Select All' const isSelectAll = mode === 'Select All'
if (isSelectAll) { if (isSelectAll) {
this.utxos.data.forEach(u => (u.selected = true)) this.utxos.forEach(u => (u.selected = true))
return return
} }
const payedAmount = this['payed-amount'] const payedAmount = this['payed-amount']
const mode = this.payment.utxoSelectionMode this.utxos.forEach(u => (u.selected = false))
this.utxos.data.forEach(u => (u.selected = false))
const isManual = mode === 'Manual' const isManual = mode === 'Manual'
if (isManual || !payedAmount) return if (isManual || !payedAmount) return
const isSmallerFirst = mode === 'Smaller Inputs First' const isSmallerFirst = mode === 'Smaller Inputs First'
const isLargerFirst = mode === 'Larger Inputs First' const isLargerFirst = mode === 'Larger Inputs First'
let selectedUtxos = this.utxos.data.slice() let selectedUtxos = this.utxos.slice()
if (isSmallerFirst || isLargerFirst) { if (isSmallerFirst || isLargerFirst) {
const sortFn = isSmallerFirst const sortFn = isSmallerFirst
? (a, b) => a.amount - b.amount ? (a, b) => a.amount - b.amount

View file

@ -85,7 +85,8 @@ const watchOnly = async () => {
showAddress: false, showAddress: false,
addressNote: '', addressNote: '',
showPayment: false showPayment: false,
fetchedUtxos: false
} }
}, },
@ -684,6 +685,7 @@ const watchOnly = async () => {
this.utxos.total = 0 this.utxos.total = 0
this.history = [] this.history = []
const addresses = this.addresses.filter(a => a.hasActivity) const addresses = this.addresses.filter(a => a.hasActivity)
console.log('### scanAddressWithAmount', this.addresses, addresses)
await this.updateUtxosForAddresses(addresses) await this.updateUtxosForAddresses(addresses)
}, },
scanAddress: async function (addressData) { scanAddress: async function (addressData) {
@ -831,6 +833,13 @@ const watchOnly = async () => {
}, },
showAddressDetails: function (addressData) { showAddressDetails: function (addressData) {
this.openQrCodeDialog(addressData) this.openQrCodeDialog(addressData)
},
initUtxos: function (addresses) {
if (!this.fetchedUtxos && addresses.length) {
this.fetchedUtxos = true
this.addresses = addresses
this.scanAddressWithAmount()
}
} }
}, },
created: async function () { created: async function () {

View file

@ -53,7 +53,7 @@
color="gray" color="gray"
class="btn-full" class="btn-full"
@click="showPayment = false" @click="showPayment = false"
>Discard Payment</q-btn >Back</q-btn
> >
</div> </div>
</div> </div>
@ -85,6 +85,7 @@
:sats-denominated="config.data.sats_denominated" :sats-denominated="config.data.sats_denominated"
@scan:address="scanAddress" @scan:address="scanAddress"
@show-address-details="showAddressDetails" @show-address-details="showAddressDetails"
@update:addresses="initUtxos"
:inkey="g.user.wallets[0].inkey" :inkey="g.user.wallets[0].inkey"
> >
</address-list> </address-list>