@@ -51,15 +51,24 @@ const LoopActions: React.FC = () => {
51
51
const {
52
52
setDirection,
53
53
inferredDirection,
54
- loopOutAllowed,
55
- loopInAllowed,
54
+ isLoopOutMinimumMet,
55
+ isLoopInMinimumMet,
56
+ hasValidLoopInPeers,
56
57
} = buildSwapStore ;
57
58
const handleLoopOut = useCallback ( ( ) => setDirection ( SwapDirection . OUT ) , [
58
59
setDirection ,
59
60
] ) ;
60
61
const handleLoopIn = useCallback ( ( ) => setDirection ( SwapDirection . IN ) , [ setDirection ] ) ;
61
62
const selectedCount = buildSwapStore . selectedChanIds . length ;
62
63
64
+ let note =
65
+ ! isLoopOutMinimumMet || ! isLoopInMinimumMet
66
+ ? l ( 'loopMinimumNote' , { min : formatSats ( buildSwapStore . termsForDirection . min ) } )
67
+ : '' ;
68
+ if ( ! hasValidLoopInPeers ) {
69
+ note = l ( 'loopInNote' ) ;
70
+ }
71
+
63
72
const { Wrapper, Actions, ActionBar, CloseIcon, Selected, Note } = Styled ;
64
73
return (
65
74
< Wrapper >
@@ -69,31 +78,27 @@ const LoopActions: React.FC = () => {
69
78
< CloseIcon onClick = { buildSwapStore . cancel } />
70
79
< Selected count = { selectedCount } />
71
80
< Button
72
- primary = { loopOutAllowed && inferredDirection === SwapDirection . OUT }
81
+ primary = { isLoopOutMinimumMet && inferredDirection === SwapDirection . OUT }
73
82
borderless
74
83
onClick = { handleLoopOut }
75
- disabled = { ! loopOutAllowed }
84
+ disabled = { ! isLoopOutMinimumMet }
76
85
>
77
86
{ l ( 'common.loopOut' ) }
78
87
</ Button >
79
88
< Button
80
- primary = { loopInAllowed && inferredDirection === SwapDirection . IN }
89
+ primary = {
90
+ hasValidLoopInPeers &&
91
+ isLoopInMinimumMet &&
92
+ inferredDirection === SwapDirection . IN
93
+ }
81
94
borderless
82
95
onClick = { handleLoopIn }
83
- disabled = { ! loopInAllowed }
96
+ disabled = { ! hasValidLoopInPeers || ! isLoopInMinimumMet }
84
97
>
85
98
{ l ( 'common.loopIn' ) }
86
99
</ Button >
87
100
</ ActionBar >
88
- { ! loopOutAllowed && ! loopInAllowed ? (
89
- < Note >
90
- { l ( 'loopMinimumNote' , {
91
- min : formatSats ( buildSwapStore . termsForDirection . min ) ,
92
- } ) }
93
- </ Note >
94
- ) : ! loopInAllowed ? (
95
- < Note > { l ( 'loopInNote' ) } </ Note >
96
- ) : null }
101
+ { note && < Note > { note } </ Note > }
97
102
</ Actions >
98
103
) : (
99
104
< Button onClick = { buildSwapStore . startSwap } >
0 commit comments