Skip to content

Commit

Permalink
fix: retrigger of generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Jul 14, 2023
1 parent 416768a commit 6b38f2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const createPaymentRequest = (

// The hook should setState(Loading) before calling this
const generateQuote: () => Promise<PaymentRequest> = async () => {
const { creationData: pr, mutations } = params
const { creationData, mutations } = params
const pr = {...creationData} // clone creation data object

let info: PaymentRequestInformation | undefined

Expand Down
9 changes: 5 additions & 4 deletions app/screens/receive-bitcoin-screen/use-receive-bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, useEffect, useMemo, useState } from "react"
import { useEffect, useMemo, useState } from "react"
import {
BaseCreatePaymentRequestCreationDataParams,
Invoice,
Expand Down Expand Up @@ -168,7 +168,7 @@ export const useReceiveBitcoin = () => {

const { convertMoneyAmount: _convertMoneyAmount } = usePriceConversion()

// Initialize Payment Request
// Initialize Payment Request Creation Data
useEffect(() => {
if (
prcd === null &&
Expand Down Expand Up @@ -201,7 +201,7 @@ export const useReceiveBitcoin = () => {
}
}, [_convertMoneyAmount, defaultWallet, bitcoinWallet, username])

// Initialize Payment Quotation
// Initialize Payment Request
useEffect(() => {
if (prcd) {
setPR(
Expand All @@ -216,6 +216,7 @@ export const useReceiveBitcoin = () => {
prcd?.unitOfAccountAmount,
prcd?.memo,
prcd?.receivingWalletDescriptor,
prcd?.username,
setPR,
])

Expand All @@ -233,7 +234,7 @@ export const useReceiveBitcoin = () => {
}
}, [pr?.state])

// Hack - Setting it to idle would trigger last useEffect hook
// Setting it to idle would trigger last useEffect hook to regenerate invoice
const regenerateInvoice = () => {
if (expiresInSeconds === 0) setPR((pq) => pq && pq.setState(PaymentRequestState.Idle))
}
Expand Down

0 comments on commit 6b38f2e

Please sign in to comment.