Browse Source

fix(payment): setTimeout for 10 seconds after sending a payment. if LND hangs while sending a payment we wont show the loading screen forever lol we'll remove it and show an error after 10 seconds

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
0f55af6129
  1. 11
      app/reducers/payment.js

11
app/reducers/payment.js

@ -57,9 +57,18 @@ export const fetchPayments = () => (dispatch) => {
// Receive IPC event for payments
export const receivePayments = (event, { payments }) => dispatch => dispatch({ type: RECEIVE_PAYMENTS, payments })
export const payInvoice = paymentRequest => (dispatch) => {
export const payInvoice = paymentRequest => (dispatch, getState) => {
dispatch(sendPayment())
ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } })
// if LND hangs on sending the payment we'll cut it after 10 seconds and return an error
setTimeout(() => {
const { payment } = getState()
if (payment.sendingPayment) {
dispatch(paymentFailed(null, { error: `Shoot, we're having some trouble sending your payment.` }))
}
}, 10000)
}
// Receive IPC event for successful payment

Loading…
Cancel
Save