Skip to content

Commit 1b39599

Browse files
committed
Fix bug where refund shown when already claimed
1 parent cfd825f commit 1b39599

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/actions/transactions.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,30 @@ function setStep (transactions, isPartyB, dispatch) {
4242
}
4343

4444
function setLocation (swap, currentLocation, dispatch) {
45+
// Do not navigate away from backup link
46+
if (currentLocation.pathname === '/backupLink') return
47+
48+
const hasInitiated = swap.transactions.a.fund.hash && swap.transactions.a.fund.confirmations > 0
4549
const hasRefunded = swap.transactions.a.refund && swap.transactions.a.refund.hash
46-
const canNavigate = currentLocation.pathname !== '/backupLink' && (hasRefunded || currentLocation.pathname !== '/refund')
47-
if (canNavigate) {
48-
const hasInitiated = swap.transactions.a.fund.hash && swap.transactions.a.fund.confirmations > 0
49-
const canRefund = !swap.transactions.b.claim.hash || swap.transactions.b.claim.confirmations === 0
50-
const swapExpiration = getFundExpiration(swap.expiration, swap.isPartyB ? 'b' : 'a').time
51-
const swapExpired = moment().isAfter(swapExpiration)
52-
if (hasInitiated && canRefund && swapExpired) {
53-
if (hasRefunded) {
54-
dispatch(replace('/refunded'))
55-
} else {
56-
dispatch(replace('/refund'))
57-
}
58-
} else if (swap.step === steps.AGREEMENT && currentLocation.pathname !== '/waiting') {
59-
if (swap.isPartyB || swap.transactions.b.fund.hash) {
60-
dispatch(replace('/waiting'))
61-
} else {
62-
dispatch(replace('/counterPartyLink'))
63-
}
64-
} else if (swap.step === steps.CLAIMING) {
65-
dispatch(replace('/redeem'))
66-
} else if (swap.step === steps.SETTLED) {
67-
dispatch(replace('/completed'))
50+
const canRefund = !swap.transactions.b.claim.hash || swap.transactions.b.claim.confirmations === 0
51+
const swapExpiration = getFundExpiration(swap.expiration, swap.isPartyB ? 'b' : 'a').time
52+
const swapExpired = moment().isAfter(swapExpiration)
53+
if (hasInitiated && canRefund && swapExpired) {
54+
if (hasRefunded) {
55+
dispatch(replace('/refunded'))
56+
} else {
57+
dispatch(replace('/refund'))
58+
}
59+
} else if (swap.step === steps.AGREEMENT && currentLocation.pathname !== '/waiting') {
60+
if (swap.isPartyB || swap.transactions.b.fund.hash) {
61+
dispatch(replace('/waiting'))
62+
} else {
63+
dispatch(replace('/counterPartyLink'))
6864
}
65+
} else if (swap.step === steps.CLAIMING) {
66+
dispatch(replace('/redeem'))
67+
} else if (swap.step === steps.SETTLED) {
68+
dispatch(replace('/completed'))
6969
}
7070
}
7171

0 commit comments

Comments
 (0)