Skip to content

Commit

Permalink
enhancement: clearing the form when changing active session
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jul 22, 2023
1 parent 4731207 commit 88a18dc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pages/evm/swap/form.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import {Asset as CoreAsset} from '@greymass/eosio'
import {currentAccountBalance, evmAccount} from '~/store'
import {currentAccountBalance, evmAccount, activeSession} from '~/store'
import Label from '~/components/elements/input/label.svelte'
import Form from '~/components/elements/form.svelte'
Expand All @@ -10,7 +10,7 @@
export let handleContinue: () => void
export let amount: string = '0.0001'
export let transferOption: string = 'nativeToEvm'
export let transferOption: string | undefined
let evmBalance: CoreAsset | undefined
let validAmount = false
Expand All @@ -35,6 +35,11 @@
}
}
function resetForm() {
transferOption = undefined
amount = ''
}
$: {
$evmAccount?.getBalance().then((balance) => {
evmBalance = CoreAsset.from(Number(balance.split(' ')[0]), '4,EOS')
Expand All @@ -43,6 +48,11 @@
$: nativeToEVMLabel = `Native (${$currentAccountBalance})`
$: evmToNativeLabel = `EVM (${evmBalance ? evmBalance : 'not connected'})`
$: {
if ($activeSession?.identifier) {
resetForm()
}
}
</script>

<style type="scss">
Expand Down

0 comments on commit 88a18dc

Please sign in to comment.