Skip to content

Commit

Permalink
fix(LIVE-11325/llm/sync onboarding) Fix nav error when finishing Reco…
Browse files Browse the repository at this point in the history
…ver backup
  • Loading branch information
mbertin-ledger committed Apr 19, 2024
1 parent f4d8d5b commit 5fdf0ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ export const SyncOnboardingCompanion: React.FC<SyncOnboardingCompanionProps> = (

const addedToKnownDevices = useRef(false);
useEffect(() => {
if (companionStepKey >= CompanionStepKey.Apps) {
// Stops the polling once the installation apps step is reached
if (companionStepKey >= CompanionStepKey.Backup) {
// Stops the polling once the device is seeded
setIsPollingOn(false);
// At this step, device has been successfully setup so it can be saved in
// the list of known devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import Link from "~/components/wrappedUi/Link";
import { NavigatorName, ScreenName } from "~/const";
import { SyncOnboardingScreenProps } from "../SyncOnboardingScreenProps";
import { TrackScreen, track } from "~/analytics";
import { useDispatch } from "react-redux";
import { completeOnboarding, setHasOrderedNano, setReadOnlyMode } from "~/actions/settings";
import { RootNavigation } from "~/components/RootNavigator/types/helpers";

const { BodyText, SubtitleText } = VerticalTimeline;

Expand Down Expand Up @@ -63,11 +66,34 @@ const VideoLink = ({ onPress }: { onPress(): void }) => {
const BackupBody: React.FC<ChoiceBodyProps> = ({ isOpened, device }) => {
const { t } = useTranslation();
const { space } = useTheme();
const dispatchRedux = useDispatch();

const navigation = useNavigation<SyncOnboardingScreenProps["navigation"]>();

const servicesConfig = useFeature("protectServicesMobile");

const navigateToRecover = useCallback(() => {
//Consider Onboarding as completed when user navigates to recover
dispatchRedux(setReadOnlyMode(false));
dispatchRedux(setHasOrderedNano(false));
dispatchRedux(completeOnboarding());
(navigation as unknown as RootNavigation).reset({
index: 0,
routes: [
{
name: NavigatorName.Base,
state: {
routes: [
{
name: NavigatorName.Main,
},
],
},
},
],
});

//Open Live App Recover
navigation.navigate(NavigatorName.Base, {
screen: ScreenName.Recover,
params: {
Expand All @@ -78,7 +104,7 @@ const BackupBody: React.FC<ChoiceBodyProps> = ({ isOpened, device }) => {
date: new Date().toISOString(), // adding a date to reload the page in case of same device restored again
},
});
}, [device, navigation, servicesConfig?.params?.protectId]);
}, [device, dispatchRedux, navigation, servicesConfig?.params?.protectId]);

return isOpened ? (
<Flex rowGap={space[3]}>
Expand Down

0 comments on commit 5fdf0ee

Please sign in to comment.