-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add shortcut buttons and address list to Token Details Modal #1237
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
abead37
Add shortcut buttons in token details modal
nop33 205f337
Initialize amounts with selected token
nop33 c8ed474
Address list in token details modal
nop33 4d02c23
Fix type errors
nop33 0b104b5
Cleanup
nop33 97229d7
Move onramper code to shared
nop33 fead26c
Create token details modal tabs
nop33 9fef815
Optimize performance when switching tabs
nop33 4d21b00
Optimize performance by freezing invisible content
nop33 718aa20
Remove unused files
nop33 2b60de1
Enable token activity tab
nop33 7b2dbe3
Fix no filtered tx message
nop33 b63cba3
Fix type errors
nop33 889fc8d
Fix wallet unlock glitch
nop33 cc04372
Cleanup
nop33 d9e206b
Reduce runs of combine Tanstack functions
nop33 3cfef3f
Fix tab rerendering on mouse over
nop33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 9 additions & 50 deletions
59
apps/desktop-wallet/src/api/apiDataHooks/wallet/useFetchWalletSingleTokenBalances.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,28 @@ | ||
import { ALPH } from '@alephium/token-list' | ||
import { useQueries, UseQueryResult } from '@tanstack/react-query' | ||
import { useMemo } from 'react' | ||
|
||
import { SkipProp } from '@/api/apiDataHooks/apiDataHooksTypes' | ||
import { combineIsLoading } from '@/api/apiDataHooks/apiDataHooksUtils' | ||
import useFetchWalletBalancesAlph from '@/api/apiDataHooks/wallet/useFetchWalletBalancesAlph' | ||
import { addressTokensBalancesQuery, AddressTokensBalancesQueryFnData } from '@/api/queries/addressQueries' | ||
import { useAppSelector } from '@/hooks/redux' | ||
import { useUnsortedAddressesHashes } from '@/hooks/useUnsortedAddresses' | ||
import { selectCurrentlyOnlineNetworkId } from '@/storage/network/networkSelectors' | ||
import { ApiBalances, TokenId } from '@/types/tokens' | ||
import useFetchWalletBalancesTokensArray from '@/api/apiDataHooks/wallet/useFetchWalletBalancesTokensArray' | ||
import { TokenId } from '@/types/tokens' | ||
|
||
interface UseFetchWalletSingleTokenBalancesProps extends SkipProp { | ||
tokenId: TokenId | ||
} | ||
|
||
const useFetchWalletSingleTokenBalances = ({ tokenId, skip }: UseFetchWalletSingleTokenBalancesProps) => { | ||
const networkId = useAppSelector(selectCurrentlyOnlineNetworkId) | ||
const allAddressHashes = useUnsortedAddressesHashes() | ||
|
||
const useFetchWalletSingleTokenBalances = ({ tokenId }: UseFetchWalletSingleTokenBalancesProps) => { | ||
const isALPH = tokenId === ALPH.id | ||
|
||
const { data: alphBalances, isLoading: isLoadingAlphBalances } = useFetchWalletBalancesAlph() | ||
|
||
const { data: tokenBalances, isLoading: isLoadingTokenBalances } = useQueries({ | ||
queries: | ||
!isALPH && !skip | ||
? allAddressHashes.map((addressHash) => addressTokensBalancesQuery({ addressHash, networkId })) | ||
: [], | ||
combine: useMemo( | ||
() => (results: UseQueryResult<AddressTokensBalancesQueryFnData>[]) => combineTokenBalances(tokenId, results), | ||
[tokenId] | ||
) | ||
}) | ||
const { data: tokensBalances, isLoading: isLoadingTokensBalances } = useFetchWalletBalancesTokensArray() | ||
|
||
return { | ||
data: isALPH ? alphBalances : tokenBalances, | ||
isLoading: isALPH ? isLoadingAlphBalances : isLoadingTokenBalances | ||
data: useMemo( | ||
() => (isALPH ? alphBalances : tokensBalances.find(({ id }) => id === tokenId)), | ||
[alphBalances, isALPH, tokenId, tokensBalances] | ||
), | ||
isLoading: isALPH ? isLoadingAlphBalances : isLoadingTokensBalances | ||
} | ||
} | ||
|
||
export default useFetchWalletSingleTokenBalances | ||
|
||
const combineTokenBalances = (tokenId: string, results: UseQueryResult<AddressTokensBalancesQueryFnData>[]) => ({ | ||
data: results.reduce( | ||
(totalBalances, { data }) => { | ||
const balances = data?.balances.find(({ id }) => id === tokenId) | ||
|
||
totalBalances.totalBalance = ( | ||
BigInt(totalBalances.totalBalance) + BigInt(balances ? balances.totalBalance : 0) | ||
).toString() | ||
totalBalances.lockedBalance = ( | ||
BigInt(totalBalances.lockedBalance) + BigInt(balances ? balances.lockedBalance : 0) | ||
).toString() | ||
totalBalances.availableBalance = ( | ||
BigInt(totalBalances.availableBalance) + BigInt(balances ? balances.availableBalance : 0) | ||
).toString() | ||
|
||
return totalBalances | ||
}, | ||
{ | ||
totalBalance: '0', | ||
lockedBalance: '0', | ||
availableBalance: '0' | ||
} as ApiBalances | ||
), | ||
...combineIsLoading(results) | ||
}) |
47 changes: 0 additions & 47 deletions
47
apps/desktop-wallet/src/api/apiDataHooks/wallet/useFetchWalletTransactionsLimited.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was introduced to improve performance by "freezing" the hidden tab content after I improved the tab navigation everywhere by keeping the previous tab mounted.