fix: note update

This commit is contained in:
Vlad Stan 2022-08-03 10:35:34 +03:00
parent f11a51a4cc
commit f1976e624d
3 changed files with 9 additions and 5 deletions

View file

@ -110,6 +110,9 @@ async function addressList(path) {
}, },
searchInTab: function (tab, value) { searchInTab: function (tab, value) {
this.$emit('search:tab', {tab, value}) this.$emit('search:tab', {tab, value})
},
updateNoteForAddress: async function (addressData, note) {
this.$emit('update:note', {addressId: addressData.id, note})
} }
}, },

View file

@ -98,17 +98,17 @@ const watchOnly = async () => {
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)
} }
}, },
updateNoteForAddress: async function (addressData, note) { updateNoteForAddress: async function ({addressId, note}) {
try { try {
const wallet = this.g.user.wallets[0] const wallet = this.g.user.wallets[0]
await LNbits.api.request( await LNbits.api.request(
'PUT', 'PUT',
`/watchonly/api/v1/address/${addressData.id}`, `/watchonly/api/v1/address/${addressId}`,
wallet.adminkey, wallet.adminkey,
{note: addressData.note} {note}
) )
const updatedAddress = const updatedAddress =
this.addresses.find(a => a.id === addressData.id) || {} this.addresses.find(a => a.id === addressId) || {}
updatedAddress.note = note updatedAddress.note = note
} catch (err) { } catch (err) {
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)

View file

@ -99,6 +99,7 @@
@show-address-details="showAddressDetails" @show-address-details="showAddressDetails"
@update:addresses="initUtxos" @update:addresses="initUtxos"
@search:tab="searchInTab" @search:tab="searchInTab"
@update:note="updateNoteForAddress"
:inkey="g.user.wallets[0].inkey" :inkey="g.user.wallets[0].inkey"
> >
</address-list> </address-list>
@ -200,7 +201,7 @@
outline outline
v-close-popup v-close-popup
color="grey" color="grey"
@click="updateNoteForAddress(currentAddress, addressNote)" @click="updateNoteForAddress({addressId: currentAddress.id, note: addressNote})"
class="q-ml-sm" class="q-ml-sm"
>Save Note</q-btn >Save Note</q-btn
> >