feat: show not enough stock message

This commit is contained in:
Tiago Vasconcelos 2023-03-20 10:45:55 +00:00
parent e6f7dc85e0
commit 4a69f023b3
2 changed files with 16 additions and 28 deletions

View file

@ -215,7 +215,10 @@
>
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<div class="text-center q-mb-lg">
<a :href="'lightning:' + qrCodeDialog.data.payment_request">
<div class="q-my-lg" v-if="qrCodeDialog.data.message">
<p>{{ qrCodeDialog.data.message }}</p>
</div>
<a v-else :href="'lightning:' + qrCodeDialog.data.payment_request">
<q-responsive :ratio="1" class="q-mx-xl">
<qrcode
v-if="qrCodeDialog.data.payment_request"

View file

@ -204,7 +204,8 @@ async function customerStall(path) {
openQrCodeDialog() {
this.qrCodeDialog = {
data: {
payment_request: null
payment_request: null,
message: null
},
dismissMsg: this.$q.notify({
message: 'Waiting for invoice from merchant...'
@ -214,6 +215,10 @@ async function customerStall(path) {
},
closeQrCodeDialog() {
this.qrCodeDialog.show = false
this.qrCodeDialog.data = {
payment_request: null,
message: null
}
setTimeout(() => {
this.qrCodeDialog.dismissMsg()
}, 1000)
@ -277,32 +282,7 @@ async function customerStall(path) {
let pub = this.pool.publish(Array.from(this.relays), order)
pub.on('ok', () => console.debug(`Order event was sent`))
pub.on('failed', error => console.error(error))
// for (const url of Array.from(this.relays)) {
// try {
// let relay = NostrTools.relayInit(url)
// relay.on('connect', () => {
// console.debug(`connected to ${relay.url}`)
// })
// relay.on('error', () => {
// console.debug(`failed to connect to ${relay.url}`)
// relay.close()
// return
// })
// await relay.connect()
// let pub = relay.publish(order)
// pub.on('ok', () => {
// console.debug(`${relay.url} has accepted our event: ${order.id}`)
// relay.close()
// })
// pub.on('failed', reason => {
// console.debug(`failed to publish to ${relay.url}: ${reason}`)
// relay.close()
// })
// } catch (err) {
// console.error(`Error: ${err}`)
// }
// }
this.loading = false
this.resetCart()
this.openQrCodeDialog()
@ -311,7 +291,6 @@ async function customerStall(path) {
async listenMessages() {
this.loading = true
try {
// const pool = new NostrTools.SimplePool()
const filters = [
{
kinds: [4],
@ -357,6 +336,12 @@ async function customerStall(path) {
if (!isJson(text)) return
let json = JSON.parse(text)
if (json.id != this.activeOrder) return
if (json.payment_options.length == 0 && json.message) {
this.loading = false
this.qrCodeDialog.data.message = json.message
return cb()
}
if (json.payment_options) {
let payment_request = json.payment_options.find(o => o.type == 'ln')
.link