Skip to content

Commit

Permalink
fix: 🐛 Fix Blank account screen when removing account from LLD when L…
Browse files Browse the repository at this point in the history
…S activated (#7826)
  • Loading branch information
mcayuelas-ledger committed Sep 18, 2024
1 parent c4309b1 commit cbac385
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-ducks-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Fix Blank account screen when removing account from LLD when LS activated
27 changes: 23 additions & 4 deletions apps/ledger-live-mobile/src/screens/Account/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from "react";
import React, { useState, useCallback, useEffect } from "react";
import { FlatList, LayoutChangeEvent, ListRenderItemInfo } from "react-native";
import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated";
import { useDispatch, useSelector } from "react-redux";
Expand All @@ -23,7 +23,7 @@ import {
import { accountScreenSelector } from "~/reducers/accounts";
import { track, TrackScreen } from "~/analytics";
import accountSyncRefreshControl from "~/components/accountSyncRefreshControl";
import { ScreenName } from "~/const";
import { NavigatorName, ScreenName } from "~/const";
import CurrencyBackgroundGradient from "~/components/CurrencyBackgroundGradient";
import AccountHeader from "./AccountHeader";
import { getListHeaderComponents } from "./ListHeaderComponent";
Expand All @@ -35,7 +35,11 @@ import EmptyAccountCard from "./EmptyAccountCard";
import useAccountActions from "./hooks/useAccountActions";
import type { AccountsNavigatorParamList } from "~/components/RootNavigator/types/AccountsNavigator";
import type { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator";
import type { StackNavigatorProps } from "~/components/RootNavigator/types/helpers";
import type {
RootNavigationComposite,
StackNavigatorNavigation,
StackNavigatorProps,
} from "~/components/RootNavigator/types/helpers";
import { getCurrencyConfiguration } from "@ledgerhq/live-common/config/index";
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";

Expand All @@ -50,7 +54,22 @@ const AnimatedFlatListWithRefreshControl = Animated.createAnimatedComponent(
/** If deep linking params are present, this Account Screen is redirected to from Accounts Screen. */
function AccountScreen({ route }: Props) {
const { account, parentAccount } = useSelector(accountScreenSelector(route));

const navigation =
useNavigation<RootNavigationComposite<StackNavigatorNavigation<BaseNavigatorStackParamList>>>();

useEffect(() => {
if (!account) {
navigation.navigate(NavigatorName.Base, {
screen: NavigatorName.Main,
params: {
screen: NavigatorName.Portfolio,
params: {
screen: NavigatorName.WalletTab,
},
},
});
}
}, [account, navigation]);
if (!account) return null;

return <AccountScreenInner account={account} parentAccount={parentAccount || undefined} />;
Expand Down

0 comments on commit cbac385

Please sign in to comment.