Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Reset user inputs while changing wallet type #1962

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

## Add

- [Ledger] Add liquidity using Ledger [#1926](https://github.com/thorchain/asgardex-electron/pull/1926), [#1927](https://github.com/thorchain/asgardex-electron/issues/1927) [#1936](https://github.com/thorchain/asgardex-electron/issues/1936)
- [Ledger] Add liquidity using Ledger [#1926](https://github.com/thorchain/asgardex-electron/pull/1926), [#1927](https://github.com/thorchain/asgardex-electron/issues/1927) [#1936](https://github.com/thorchain/asgardex-electron/issues/1936), [#1962](https://github.com/thorchain/asgardex-electron/pull/1962)
- [ADD] Update shares for Ledger [#1942](https://github.com/thorchain/asgardex-electron/pull/1942)
- Restore previous windows dimensions with next start of ASGDX [#1879](https://github.com/thorchain/asgardex-electron/issues/1879)
- Show asset icon in TxDetail (wallet history + pool details)[#1955](https://github.com/thorchain/asgardex-electron/pull/1955)
- [ADD] Check asset mismatch for Ledger + keystore [#1938](https://github.com/thorchain/asgardex-electron/issues/1938)
- Show ledger | keystore addresses in tooltips [#1959](https://github.com/thorchain/asgardex-electron/pull/1959)
- Whitelist TGT token [#1960](https://github.com/thorchain/asgardex-electron/issues/1960)

## Update

Expand Down
36 changes: 28 additions & 8 deletions src/renderer/components/deposit/add/SymDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,32 @@ export const SymDeposit: React.FC<Props> = (props) => {
)
}, [asset, network, symAssetMismatchRD])

const resetEnteredAmounts = useCallback(() => {
setRuneAmountToDeposit(baseAmount(0, THORCHAIN_DECIMAL))
setAssetAmountToDepositMax1e8(initialAssetAmountToDepositMax1e8)
setPercentValueToDeposit(0)
}, [initialAssetAmountToDepositMax1e8, setAssetAmountToDepositMax1e8])

const onChangeRuneWalletType = useCallback(
(walletType) => {
setRuneLedger(() => isLedgerWallet(walletType))
setRuneWalletType(walletType)
resetEnteredAmounts()
},

[resetEnteredAmounts, setRuneWalletType]
)

const onChangeAssetWalletType = useCallback(
(walletType) => {
setUseAssetLedger(() => isLedgerWallet(walletType))
setAssetWalletType(walletType)

resetEnteredAmounts()
},
[resetEnteredAmounts, setAssetWalletType]
)

const prevRouterAddress = useRef<O.Option<Address>>(O.none)

// Run `checkApprovedStatus` whenever `oPoolAddress` has been changed
Expand Down Expand Up @@ -1437,10 +1463,7 @@ export const SymDeposit: React.FC<Props> = (props) => {
walletTypeTooltipColor={assetWalletTypeTooltip.color}
// Disable ledger selection if RUNE Ledger has been selected
walletTypeDisabled={!hasAssetLedger || useRuneLedger}
onChangeWalletType={(walletType) => {
setUseAssetLedger(() => isLedgerWallet(walletType))
setAssetWalletType(walletType)
}}
onChangeWalletType={onChangeAssetWalletType}
assetBalance={assetBalance}
disabled={disabledForm}
asset={{
Expand Down Expand Up @@ -1481,10 +1504,7 @@ export const SymDeposit: React.FC<Props> = (props) => {
walletTypeTooltipColor={runeWalletTypeTooltip.color}
// Disable ledger checkbox if asset ledger is used
walletTypeDisabled={!hasRuneLedger || useAssetLedger}
onChangeWalletType={(walletType) => {
setRuneLedger(() => isLedgerWallet(walletType))
setRuneWalletType(walletType)
}}
onChangeWalletType={onChangeRuneWalletType}
assetBalance={runeBalance}
disabled={disabledForm}
asset={{
Expand Down