Skip to content

Commit a377c52

Browse files
Merge pull request #814 from Adamant-im/feat/handle-wallets
Fix: remove question sign logic and don't show ... while loading balances
2 parents 2653428 + 33916e9 commit a377c52

File tree

7 files changed

+51
-33
lines changed

7 files changed

+51
-33
lines changed

src/components/WalletTab.vue

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
<crypto-icon :class="classes.cryptoIcon" :crypto="wallet.cryptoCurrency" size="medium" />
33

44
<div>
5-
<div v-if="formattedBalance">{{ isBalanceValid ? formattedBalance : '...' }}</div>
6-
<div v-else-if="isBalanceLoading" :class="classes.balanceLoading">
5+
<div v-if="isBalanceValid && !isRefreshing">{{ formattedBalance }}</div>
6+
<div v-else :class="classes.balanceLoading">
77
<v-icon :icon="mdiDotsHorizontal" size="18" />
88
</div>
9-
<div v-else :class="classes.balanceError">
10-
<v-icon :icon="mdiHelpCircleOutline" size="18" />
11-
</div>
129

1310
<div>
1411
{{ wallet.cryptoCurrency }}
@@ -27,10 +24,9 @@
2724
import { computed, watch } from 'vue'
2825
import { useStore } from 'vuex'
2926
30-
import { Cryptos, FetchStatus } from '@/lib/constants'
3127
import CryptoIcon from '@/components/icons/CryptoIcon.vue'
3228
import numberFormat from '@/filters/numberFormat'
33-
import { mdiDotsHorizontal, mdiHelpCircleOutline } from '@mdi/js'
29+
import { mdiDotsHorizontal } from '@mdi/js'
3430
import { vibrate } from '@/lib/vibrate'
3531
3632
const className = 'wallet-tab'
@@ -57,6 +53,7 @@ type Props = {
5753
wallet: Wallet
5854
fiatCurrency: string
5955
isBalanceValid: boolean
56+
isRefreshing: boolean
6057
}
6158
6259
const props = defineProps<Props>()
@@ -66,29 +63,8 @@ const store = useStore()
6663
const currentBalance = computed(() => props.wallet.balance)
6764
6865
const isRateLoaded = computed(() => store.state.rate.isLoaded && props.wallet.rate)
69-
const balanceStatus = computed(() => {
70-
const { cryptoCurrency } = props.wallet
71-
const cryptoModuleName = cryptoCurrency.toLowerCase()
72-
73-
if (cryptoCurrency === Cryptos.ADM) {
74-
return store.state.balanceStatus
75-
}
76-
77-
return store.state[cryptoModuleName].balanceStatus
78-
})
7966
80-
const isBalanceLoading = computed(() => balanceStatus.value === FetchStatus.Loading)
81-
const fetchBalanceSucceeded = computed(() => balanceStatus.value === FetchStatus.Success)
82-
83-
const formattedBalance = computed(() => {
84-
const formatted = numberFormat(props.wallet.balance, 4)
85-
86-
if (props.wallet.balance || fetchBalanceSucceeded.value) {
87-
return formatted
88-
}
89-
90-
return null
91-
})
67+
const formattedBalance = computed(() => numberFormat(props.wallet.balance, 4))
9268
9369
watch(currentBalance, (newBalance, oldBalance) => {
9470
if (oldBalance < newBalance) {

src/hooks/useBalanceCheck.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function useBalanceCheck() {
3131
)
3232

3333
const updateBalance = async () => {
34+
await store.dispatch('requestBalanceUpdate')
3435
await store.dispatch('updateBalance', {
3536
requestedByUser: true
3637
})

src/store/modules/btc-base/btc-base-actions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ function createActions(options) {
106106
}
107107
},
108108

109+
/** Wrapper to manually request balance update if needed */
110+
requestBalanceUpdate: {
111+
root: true,
112+
handler({ dispatch }) {
113+
dispatch('updateBalance')
114+
}
115+
},
116+
109117
initBalanceUpdate: {
110118
root: true,
111119
handler({ dispatch }) {

src/store/modules/erc20/erc20-actions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ const createSpecificActions = (api) => ({
6767
}
6868
},
6969

70+
/** Wrapper to manually request balance update if needed */
71+
requestBalanceUpdate: {
72+
root: true,
73+
handler({ dispatch }) {
74+
dispatch('updateBalance')
75+
}
76+
},
77+
7078
initBalanceUpdate: {
7179
root: true,
7280
handler({ dispatch }) {

src/store/modules/eth/actions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ const createSpecificActions = (api) => ({
6868
}
6969
},
7070

71+
/** Wrapper to manually request balance update if needed */
72+
requestBalanceUpdate: {
73+
root: true,
74+
handler({ dispatch }) {
75+
dispatch('updateBalance')
76+
}
77+
},
78+
7179
initBalanceUpdate: {
7280
root: true,
7381
handler({ dispatch }) {

src/store/modules/kly/kly-actions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ const customActions = (getAccount) => ({
3333
}
3434
},
3535

36+
/** Wrapper to manually request balance update if needed */
37+
requestBalanceUpdate: {
38+
root: true,
39+
handler({ dispatch }) {
40+
dispatch('updateBalance')
41+
}
42+
},
43+
3644
initBalanceUpdate: {
3745
root: true,
3846
handler({ dispatch }) {

src/views/Home.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:wallet="wallet"
2525
:fiat-currency="currentCurrency"
2626
:is-balance-valid="balances[index]"
27+
:is-refreshing="isRefreshing"
2728
/>
2829
</v-tab>
2930
</v-tabs>
@@ -79,7 +80,7 @@ import { PullDown } from '@/components/common/PullDown'
7980
import { Cryptos, CryptosInfo, CryptoSymbol, isErc20 } from '@/lib/constants'
8081
import { vibrate } from '@/lib/vibrate'
8182
import { useStore } from 'vuex'
82-
import { computed, watch } from 'vue'
83+
import { computed, ref, watch } from 'vue'
8384
import { useRoute, useRouter } from 'vue-router'
8485
import { CoinSymbol } from '@/store/modules/wallets/types'
8586
import { useI18n } from 'vue-i18n'
@@ -95,6 +96,8 @@ const balances = useBalanceCheck()
9596
9697
const className = 'account-view'
9798
99+
const isRefreshing = ref(false)
100+
98101
const orderedVisibleWalletSymbols = computed(() => {
99102
return store.getters['wallets/getVisibleOrderedWalletSymbols']
100103
})
@@ -155,9 +158,15 @@ const updateBalances = () => {
155158
})
156159
}
157160
158-
store.dispatch('updateBalance', {
159-
requestedByUser: true
160-
})
161+
isRefreshing.value = true
162+
163+
store
164+
.dispatch('updateBalance', {
165+
requestedByUser: true
166+
})
167+
.finally(() => {
168+
isRefreshing.value = false
169+
})
161170
162171
vibrate.veryShort()
163172
}

0 commit comments

Comments
 (0)