Skip to content

Commit

Permalink
Merge pull request #949 from Koniverse/issue-942
Browse files Browse the repository at this point in the history
[issue-942] Re-check re-connect network on transaction screen
  • Loading branch information
nguyenduythuc authored Aug 16, 2023
2 parents 2c945d3 + abfc1c4 commit a45b501
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hooks/balance/useGetBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const useGetBalance = (chain = '', address = '', tokenSlug = '') => {
const [isRefresh, setIsRefresh] = useState({});
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const isChainActive = chainStateMap[chain]?.active;
const nativeTokenActive = nativeTokenSlug && assetSettingMap[nativeTokenSlug]?.visible;
const isTokenActive = assetSettingMap[tokenSlug]?.visible;

const refreshBalance = useCallback(() => {
setIsRefresh({});
Expand All @@ -34,11 +37,9 @@ const useGetBalance = (chain = '', address = '', tokenSlug = '') => {

if (address && chain) {
const promiseList = [] as Promise<any>[];
const isChainActive = chainStateMap[chain]?.active;
const nativeTokenActive = nativeTokenSlug && assetSettingMap[nativeTokenSlug]?.visible;
let childTokenActive = true;

if (tokenSlug && tokenSlug !== nativeTokenSlug && !assetSettingMap[tokenSlug]?.visible) {
if (tokenSlug && tokenSlug !== nativeTokenSlug && !isTokenActive) {
childTokenActive = false;
}

Expand Down Expand Up @@ -120,10 +121,11 @@ const useGetBalance = (chain = '', address = '', tokenSlug = '') => {
nativeTokenSlug,
tokenSlug,
isRefresh,
assetSettingMap,
chainStateMap,
assetRegistry,
chainInfo?.name,
isChainActive,
isTokenActive,
nativeTokenActive,
]);

return { refreshBalance, tokenBalance, nativeTokenBalance, nativeTokenSlug, isLoading, error };
Expand Down

0 comments on commit a45b501

Please sign in to comment.