Conversation
Theme switch is working
I wanted to try to keep Snackbars out of redux... let's see!
Using Tanstack's query instead of redux
Simplifying further
nop33
left a comment
There was a problem hiding this comment.
I'm very much happier with the changes, good job! 👏 A few more small comments.
| const replaced2 = replaced1.replace( | ||
| /__VITE_NODE_URL__/g, | ||
| `"${process.env.VITE_NODE_URL ?? 'http://localhost:22973'}"` | ||
| ) |
There was a problem hiding this comment.
nit: I guess all these replace could simply be chained, but I don't mind much.
| "@lukemorales/query-key-factory": "^1.3.2", | ||
| "@tanstack/react-query": "^4.29.15", | ||
| "apexcharts": "^3.35.0", | ||
| "axios": "^1.4.0", |
| one: (assetId: string) => ({ | ||
| queryKey: ['assetType', assetId], | ||
| queryFn: (): Promise<AssetBase> => client.node.guessStdTokenType(assetId).then((r) => ({ id: assetId, type: r })), | ||
| staleTime: ONE_DAY_MS |
There was a problem hiding this comment.
Because it's now persisted in the local storage. I prefer to be on the safe side and refresh everyday.
| }) | ||
|
|
||
| if (isAlphIn) { | ||
| verifiedTokensMetadata.unshift({ ...ALPH, type: 'fungible', verified: true }) |
There was a problem hiding this comment.
nit: How about creating a small util object? It can be used in both places in this file.
const alphMetadata = { ...ALPH, type: 'fungible', verified: true } as VerifiedFungibleTokenMetadata| if (value !== undefined) { | ||
| amount = getAmount({ value, isFiat, decimals, nbOfDecimalsToShow, fullPrecision }) | ||
|
|
||
| if (fadeDecimals && ['K', 'M', 'B', 'T'].some((char) => amount.endsWith(char))) { |
There was a problem hiding this comment.
I guess we need to update the list with the one from the SDK now that we added more chars!
| along with the library. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| /* eslint-disable @typescript-eslint/no-explicit-any */ |
| unsorted.unshift({ | ||
| ...ALPH, | ||
| type: 'fungible', | ||
| balance: BigInt(addressBalance.balance), | ||
| lockedBalance: BigInt(addressBalance.lockedBalance), | ||
| verified: true | ||
| }) |
There was a problem hiding this comment.
the alphMetadata I proposed above could also be used here!
| const [isHovered, setIsHovered] = useState(false) | ||
|
|
||
| const desc = nft.file?.description | ||
| const cutDesc = desc && desc?.length > 200 ? nft.file?.description?.substring(0, 200) + '...' : desc |
| const mempoolTxs = await client.addresses.getAddressesAddressMempoolTransactions(id) | ||
| const { data: addressBalance } = useQuery({ | ||
| ...addressQueries.balance.details(addressHash), | ||
| enabled: !!addressHash |
There was a problem hiding this comment.
Could we add a TODO so that this comment doesn't get forgotten?
| const mempoolTxs = await client.addresses.getAddressesAddressMempoolTransactions(id) | ||
| const { data: addressBalance } = useQuery({ | ||
| ...addressQueries.balance.details(addressHash), | ||
| enabled: !!addressHash |
There was a problem hiding this comment.
Wouldn't it be useful to add the address validity check in the enabled flags of each query so that we avoid spamming the server with unnecessary requests when the address is invalid? Or is it too much for now?
Fixes #161 #213