Skip to content

Commit

Permalink
Merge branch 'staging' into revert-996-revert-995-revert-993-revert-9…
Browse files Browse the repository at this point in the history
…91-fran/rebase-main-to-staging

* staging: (76 commits)
  fix: have nextStage call inside invoiceID match condition
  fix: responsive project headers
  fix: update project header text variants
  fix: header title fix
  v0.2.0
  chore: fix types
  chore: update types
  fix: style fixes staging (#986)
  feat: make rewards selectable only (#987)
  chore: cleanup
  fix: staging fixes + delete unused components
  fix: project layout cleanup
  fix: validate entry.id before publishing
  chore: minor cleanup
  fix: go back in history when back in entry
  fix: retry the graphql operation if the error is expired_refresh_token
  chore: cleanup
  feat: video as header (#969)
  fix: remove draft status before status loaded (#970)
  feat: create button below the left sidebar (#966)
  ...

# Conflicts:
#	src/hooks/fundingFlow/useFundingFlow.tsx
  • Loading branch information
sajald77 committed Jun 21, 2023
2 parents 8a5085e + 092ea62 commit 0350136
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/hooks/fundingFlow/useFundingFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ const requestWebLNPayment = async (fundingTx: FundingTxFragment) => {
}

export const useFundingFlow = (options?: IFundingFlowOptions) => {
useEffect(() => {
// Cleanup interval on unmount
return () => stopListening()
}, [])

const { hasBolt11 = true, hasWebLN = true } = options || {
hasBolt11: true,
hasWebLN: true,
Expand Down Expand Up @@ -128,6 +123,10 @@ export const useFundingFlow = (options?: IFundingFlowOptions) => {
const [amounts, setAmounts] =
useState<FundingMutationResponse['amountSummary']>(initialAmounts)

useEffect(() => {
return () => stopListening()
}, [stopListening])

const gotoNextStage = useCallback(() => {
setFundState((currentState) => {
const currentIndex = stageList.indexOf(currentState)
Expand Down Expand Up @@ -269,6 +268,15 @@ export const useFundingFlow = (options?: IFundingFlowOptions) => {
fundingActivity.status !== current.status) &&
fundingActivity.invoiceId === current.invoiceId
) {
if (
fundingActivity.status === FundingStatus.Paid ||
(fundingActivity.onChain &&
fundingActivity.status === FundingStatus.Pending)
) {
stopListening()
gotoNextStage()
}

return {
...current,
...fundingActivity,
Expand All @@ -278,15 +286,6 @@ export const useFundingFlow = (options?: IFundingFlowOptions) => {

return current
})

if (
fundingActivity.status === FundingStatus.Paid ||
(fundingActivity.status === FundingStatus.Pending &&
fundingActivity.onChain)
) {
stopListening()
gotoNextStage()
}
}
}, [fundingActivity, stopListening, gotoNextStage])

Expand Down

0 comments on commit 0350136

Please sign in to comment.