Skip to content
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

feat(suite-native): hide balance if discovery is still loading so it's not final #16507

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading