@@ -8,9 +8,9 @@ import { useGenerateSapphireAccount } from './withdraw/useGenerateSapphireAccoun
88import { minimalWithdrawableAmount , withdrawToConsensus } from './withdraw/withdrawToConsensus'
99
1010// Use global variable here, due to step4 using different context(not in sync with react hooks)
11- let isInputMode = true
12- const setIsInputMode = ( _isInputMode : boolean ) => {
13- isInputMode = _isInputMode
11+ let isInputModeGlobal = true
12+ const setIsInputModeGlobal = ( _isInputMode : boolean ) => {
13+ isInputModeGlobal = _isInputMode
1414}
1515
1616/**
@@ -23,6 +23,7 @@ export function useWithdraw() {
2323 useGenerateSapphireAccount ( )
2424 const [ consensusAddress , setConsensusAddress ] = useState < `oasis1${string } `> ( )
2525 const [ progress , setProgress ] = useState ( { percentage : 0 as number | undefined , message : '' } )
26+ const [ _isInputMode , _setIsInputMode ] = useState ( true )
2627 const { refetch : updateBalanceInsideConnectButton , data : availableBalance } = useBalance ( {
2728 address : sapphireAddress ,
2829 } )
@@ -99,11 +100,16 @@ export function useWithdraw() {
99100 }
100101
101102 // Loop unless in input mode, case when user click transfer more
102- if ( ! isInputMode ) {
103+ if ( ! isInputModeGlobal ) {
103104 await step4 ( consensusAddress )
104105 }
105106 }
106107
108+ function setIsInputMode ( inputMode : boolean ) {
109+ _setIsInputMode ( inputMode )
110+ setIsInputModeGlobal ( inputMode )
111+ }
112+
107113 function transferMore ( ) {
108114 setIsInputMode ( true )
109115 }
@@ -121,7 +127,7 @@ export function useWithdraw() {
121127 availableBalance,
122128 progress,
123129 isBlockingNavigatingAway,
124- isInputMode,
130+ isInputMode : _isInputMode ,
125131 setIsInputMode,
126132 isPrevError,
127133 }
0 commit comments