Skip to content

Commit

Permalink
#6 code clean-up and some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
motorina0 committed Jun 10, 2021
1 parent 6af6579 commit 98f2fc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 56 deletions.
14 changes: 9 additions & 5 deletions src/components/LnurlAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<div v-else>
<payment-status
v-if="currentView === 'authStatus'"
:isPayed="withdrawStatus.isPayed"
:message="withdrawStatus.message"
:details="withdrawStatus.details"
:isPayed="authStatus.isPayed"
:message="authStatus.message"
:details="authStatus.details"
></payment-status>
<error-card
v-else-if="currentView === 'error'"
Expand All @@ -47,15 +47,15 @@
</template>
<script>
import lnbitsApi from '../services/lnbits-api.svc'
import configSvc from '../services/config.svc'
export default {
name: 'lnurl-auth',
props: {
lnurlauth: object,
lnurlauth: Object,
},
data() {
return {
paymentChecker: null,
currentView: 'auth',
authStatus: {
isPayed: false,
Expand All @@ -69,6 +69,10 @@ export default {
},
}
},
mounted: async function () {
this.serverUrl = await configSvc.getServerUrl()
this.activeWallet = await configSvc.getActiveWallet()
},
methods: {
authLnurl: async function () {
try {
Expand Down
57 changes: 6 additions & 51 deletions src/components/PayInvoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,6 @@
</lnurl-pay>
<lnurl-withdraw v-else-if="showLnurlWithdrawDetails" :receive="receive"> </lnurl-withdraw>
<lnurl-auth v-else-if="showLnurlAuthDetails" :lnurlauth="parse.lnurlauth"> </lnurl-auth>
<div v-else-if="showPaymentStatus">
<q-card-section dark bordered>
<p class="text-center">
<q-icon v-if="paymentDetails.isPayed" name="check_circle" size="5.5em" color="green" />
<q-spinner-bars v-else color="purple" size="5.5em" />
</p>
<p class="q-my-none text-h6 text-center">{{ paymentDetails.message }}</p>
<q-expansion-item
v-if="paymentDetails.details && paymentDetails.details.length"
group="extras"
icon="info"
class="bg-yellow-1"
label="Details"
>
<span v-html="paymentDetails.details"></span>
</q-expansion-item>
</q-card-section>

<div class="row q-mt-lg">
<q-space />
<q-btn v-close-popup flat color="grey" class="q-ml-auto cursor-pointer">Close</q-btn>
<q-space />
</div>
</div>
<div v-else-if="showErrorDetais">
<q-card-section dark bordered class="bg-red-5">
<div class="text-h6">{{ error.title }}</div>
Expand Down Expand Up @@ -103,11 +79,6 @@ export default {
},
paymentChecker: null,
},
paymentDetails: {
isPayed: false,
message: '...',
details: '',
},
receive: {
show: false,
status: 'pending',
Expand Down Expand Up @@ -139,9 +110,6 @@ export default {
showErrorDetais: function () {
return this.currentView === 'error'
},
showPaymentStatus: function () {
return this.currentView === 'paymentStatus'
},
},
methods: {
Expand Down Expand Up @@ -238,26 +206,14 @@ export default {
return cleanInvoice
},
closeDialog() {
closeDialog: function () {
this.$browser.runtime.sendMessage('hide_iframe')
},
showErrorCard(err, title = 'Error') {
showErrorCard: function (err, title = 'Error') {
this.currentView = 'error'
this.error.title = title
this.error.message = (err.message || err) + '.'
},
showPaymentInProgressCard(message = 'Processing payment...') {
this.currentView = 'paymentStatus'
this.paymentDetails.isPayed = false
this.paymentDetails.message = message
this.paymentDetails.details = ''
},
showPaymentCompentedCard(details = '') {
this.currentView = 'paymentStatus'
this.paymentDetails.isPayed = true
this.paymentDetails.message = 'Success!'
this.paymentDetails.details = details
},
},
mounted: async function () {
this.showDialog = true
Expand All @@ -272,11 +228,10 @@ export default {
this.activeWallet = await configSvc.getActiveWallet()
this.decodeRequest()
} else {
this.$q.notify({
type: 'negative',
message: 'No user or wallet found!',
caption: `Please check that you are connected to a LNbits server.`,
})
this.showErrorCard(
'No user or wallet found!',
'Please check that you are connected to a LNbits server.'
)
}
} catch (err) {
console.error(err)
Expand Down
2 changes: 2 additions & 0 deletions src/views/content-inject/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InvoiceDetails from '../../components/InvoiceDetails.vue'
import PaymentStatus from '../../components/PaymentStatus.vue'
import LnurlPay from '../../components/LnurlPay.vue'
import LnurlWithdraw from '../../components/LnurlWithdraw.vue'
import LnurlAuth from '../../components/LnurlAuth.vue'
import ErrorCard from '../../components/ErrorCard.vue'

import routes from './routes'
Expand All @@ -24,6 +25,7 @@ try {
Vue.component('payment-status', PaymentStatus)
Vue.component('lnurl-pay', LnurlPay)
Vue.component('lnurl-withdraw', LnurlWithdraw)
Vue.component('lnurl-auth', LnurlAuth)
Vue.component('error-card', ErrorCard)


Expand Down

0 comments on commit 98f2fc1

Please sign in to comment.