Skip to content

Commit

Permalink
frontend: only animate after unlocking or redirect to accountsummary
Browse files Browse the repository at this point in the history
  • Loading branch information
shonsirsha committed Oct 7, 2024
1 parent 45b5192 commit 0fd6336
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontends/web/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const App = () => {
// if on index page and have at least 1 account, route to /account-summary
if (isIndex && accounts.length) {
// replace current history entry so that the user cannot go back to "index"
navigate('/account-summary', { replace: true });
navigate('/account-summary?with-chart-animation=true', { replace: true });
return;
}
// if on the /exchange/ view and there are no accounts view route to /
Expand Down
11 changes: 8 additions & 3 deletions frontends/web/src/routes/account/summary/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { getDarkmode } from '@/components/darkmode/darkmode';
import { DefaultCurrencyRotator } from '@/components/rates/rates';
import { AppContext } from '@/contexts/AppContext';
import styles from './chart.module.css';
import { useSearchParams } from 'react-router-dom';

type TProps = {
data?: TSummary;
Expand Down Expand Up @@ -97,6 +98,7 @@ export const Chart = ({

const { t, i18n } = useTranslation();
const { chartDisplay, setChartDisplay } = useContext(AppContext);
const [searchParams] = useSearchParams();

const ref = useRef<HTMLDivElement>(null);
const refToolTip = useRef<HTMLSpanElement>(null);
Expand All @@ -121,12 +123,15 @@ export const Chart = ({
toolTipLeft: 0,
toolTipTime: 0,
});

const [showAnimationOverlay, setAnimationOverlay] = useState(true);

const prevChartDataDaily = usePrevious(data.chartDataDaily);
const prevChartDataHourly = usePrevious(data.chartDataHourly);
const prevChartFiat = usePrevious(data.chartFiat);
const prevHideAmounts = usePrevious(hideAmounts);
const hasChartAnimationParam = searchParams.get('with-chart-animation');


const setFormattedData = (chartData: ChartData) => {
formattedData.current = {};
Expand Down Expand Up @@ -436,11 +441,11 @@ export const Chart = ({
}, [initChart, removeChart]);

useEffect(() => {
if (data.chartDataMissing) {
if (data.chartDataMissing || !hasChartAnimationParam) {
return;
}
setAnimationOverlay(false);
}, [data.chartDataMissing]);
}, [data.chartDataMissing, hasChartAnimationParam]);

useEffect(() => {
const { utcYear, utcMonth, utcDate, from, to } = getUTCRange();
Expand Down Expand Up @@ -539,7 +544,7 @@ export const Chart = ({
</div>
{!isMobile && <Filters {...chartFiltersProps} />}
</header>
{!chartDataMissing &&
{!chartDataMissing && hasChartAnimationParam &&
<div
style={{ minHeight: chartHeight }}
className={`
Expand Down
2 changes: 1 addition & 1 deletion frontends/web/src/routes/device/bitbox02/wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Wizard = ({ deviceID }: TProps) => {

const handleGetStarted = () => {
setShowWizard(false);
navigate('/account-summary');
navigate('/account-summary?with-chart-animation=true');
};

useEffect(() => {
Expand Down

0 comments on commit 0fd6336

Please sign in to comment.