Browse Source

feature(request global error): hook up back end global errors for request form

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
e80dd91880
  1. 8
      app/components/GlobalError/GlobalError.js
  2. 5
      app/lnd/methods/index.js
  3. 12
      app/reducers/invoice.js
  4. 3
      app/reducers/ipc.js

8
app/components/GlobalError/GlobalError.js

@ -3,9 +3,7 @@ import PropTypes from 'prop-types'
import { MdClose } from 'react-icons/lib/md' import { MdClose } from 'react-icons/lib/md'
import styles from './GlobalError.scss' import styles from './GlobalError.scss'
const GlobalError = ({ error, clearError }) => { const GlobalError = ({ error, clearError }) => (
console.log('error: ', error)
return (
<div className={`${styles.container} ${!error && styles.closed}`}> <div className={`${styles.container} ${!error && styles.closed}`}>
<div className={styles.content}> <div className={styles.content}>
<div className={styles.close} onClick={clearError}> <div className={styles.close} onClick={clearError}>
@ -14,8 +12,8 @@ const GlobalError = ({ error, clearError }) => {
<h2>{error}</h2> <h2>{error}</h2>
</div> </div>
</div> </div>
) )
}
GlobalError.propTypes = { GlobalError.propTypes = {

5
app/lnd/methods/index.js

@ -105,7 +105,10 @@ export default function (lnd, event, msg, data) {
}) })
) )
) )
.catch(error => console.log('addInvoice error: ', error)) .catch(error => {
console.log('addInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() })
})
break break
case 'sendPayment': case 'sendPayment':
// Payment looks like { payment_preimage: Buffer, payment_route: Object } // Payment looks like { payment_preimage: Buffer, payment_route: Object }

12
app/reducers/invoice.js

@ -5,6 +5,7 @@ import { fetchBalance } from './balance'
import { setFormType } from './form' import { setFormType } from './form'
import { setPayInvoice } from './payform' import { setPayInvoice } from './payform'
import { resetRequestForm } from './requestform' import { resetRequestForm } from './requestform'
import { setError } from './error'
import { showNotification } from '../notifications' import { showNotification } from '../notifications'
import { btc, usd } from '../utils' import { btc, usd } from '../utils'
@ -71,12 +72,6 @@ export function sendInvoice() {
} }
} }
export function invoiceFailed() {
return {
type: INVOICE_FAILED
}
}
// Send IPC event for a specific invoice // Send IPC event for a specific invoice
export const fetchInvoice = payreq => (dispatch) => { export const fetchInvoice = payreq => (dispatch) => {
dispatch(getInvoice()) dispatch(getInvoice())
@ -117,6 +112,11 @@ export const createdInvoice = (event, invoice) => (dispatch) => {
dispatch(resetRequestForm()) dispatch(resetRequestForm())
} }
export const invoiceFailed = (event, { error }) => dispatch => {
dispatch({ type: INVOICE_FAILED })
dispatch(setError(error))
}
// Listen for invoice updates pushed from backend from subscribeToInvoices // Listen for invoice updates pushed from backend from subscribeToInvoices
export const invoiceUpdate = (event, { invoice }) => (dispatch) => { export const invoiceUpdate = (event, { invoice }) => (dispatch) => {
dispatch({ type: UPDATE_INVOICE, invoice }) dispatch({ type: UPDATE_INVOICE, invoice })

3
app/reducers/ipc.js

@ -22,7 +22,7 @@ import {
} from './channels' } from './channels'
import { lightningPaymentUri } from './payform' import { lightningPaymentUri } from './payform'
import { receivePayments, paymentSuccessful, paymentFailed } from './payment' import { receivePayments, paymentSuccessful, paymentFailed } from './payment'
import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate } from './invoice' import { receiveInvoices, createdInvoice, receiveFormInvoice, invoiceUpdate, invoiceFailed } from './invoice'
import { receiveBalance } from './balance' import { receiveBalance } from './balance'
import { import {
receiveTransactions, receiveTransactions,
@ -48,6 +48,7 @@ const ipc = createIpc({
receiveInvoices, receiveInvoices,
receiveInvoice: receiveFormInvoice, receiveInvoice: receiveFormInvoice,
createdInvoice, createdInvoice,
invoiceFailed,
invoiceUpdate, invoiceUpdate,
receiveBalance, receiveBalance,

Loading…
Cancel
Save