Skip to content

Commit

Permalink
feat(suite-native): hide balance if discovery is still loading so it'…
Browse files Browse the repository at this point in the history
…s not final
  • Loading branch information
matejkriz committed Jan 21, 2025
1 parent cf39a44 commit b6893f7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions suite-native/graph/src/components/GraphFiatBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useSelector } from 'react-redux';

import { Atom, useAtomValue } from 'jotai';

import { FiatGraphPoint } from '@suite-common/graph';
import { Box, BoxSkeleton, DiscreetTextTrigger, HStack, VStack, Text } from '@suite-native/atoms';
import { FiatBalanceFormatter } from '@suite-native/formatters';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
import { useFormatters } from '@suite-common/formatters';
import { selectHasDeviceDiscovery } from '@suite-common/wallet-core';

import { GraphDateFormatter } from './GraphDateFormatter';
import { PriceChangeIndicator } from './PriceChangeIndicator';
Expand Down Expand Up @@ -62,13 +65,14 @@ export const GraphFiatBalance = ({
const firstGraphPoint = useAtomValue(referencePointAtom);
const { DateTimeFormatter } = useFormatters();

const hasDeviceDiscovery = useSelector(selectHasDeviceDiscovery);
const hasBalance = Number(totalFiatBalance) !== 0;
const showLoading = isLoading || !firstGraphPoint;
const showBalanceFallback =
!hasDeviceDiscovery && ((hasBalance && showLoading) || !isHistoryEnabledAccount);

// During loading or error we just show latest total balance
if (
(Number(totalFiatBalance) !== 0 && (isLoading || !firstGraphPoint)) ||
!isHistoryEnabledAccount
) {
// If discovery finished but graph still loading or missing first point we just show latest total balance
if (showBalanceFallback) {
return (
<Box style={applyStyle(wrapperStyle)}>
<Balance selectedPointAtom={selectedPointAtom} latestValue={totalFiatBalance} />
Expand Down

0 comments on commit b6893f7

Please sign in to comment.