diff --git a/.changeset/witty-fireants-hide.md b/.changeset/witty-fireants-hide.md new file mode 100644 index 000000000000..22a1fe3f6fd8 --- /dev/null +++ b/.changeset/witty-fireants-hide.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +Fix navigation lock bug after (un)installing apps, top arrow diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/CustomBlockRouterNavigator.tsx b/apps/ledger-live-mobile/src/components/RootNavigator/CustomBlockRouterNavigator.tsx index 2d52393dd55f..04439aa2d726 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/CustomBlockRouterNavigator.tsx +++ b/apps/ledger-live-mobile/src/components/RootNavigator/CustomBlockRouterNavigator.tsx @@ -65,7 +65,7 @@ export const useLockNavigation = ( useEffect(() => { exposedManagerNavLockCallback.next(when ? callback : undefined); lockSubject.next(when); - const listener = navigation.addListener("beforeRemove", e => { + const listenerCleanup = navigation.addListener("beforeRemove", e => { if (!when) { // If we don't have unsaved changes, then we don't need to do anything return; @@ -80,7 +80,7 @@ export const useLockNavigation = ( return () => { lockSubject.next(false); exposedManagerNavLockCallback.next(undefined); - navigation.removeListener("beforeRemove", listener); + listenerCleanup(); }; }, [callback, navigation, when]); }; diff --git a/apps/ledger-live-mobile/src/screens/PostOnboarding/PostOnboardingHub.tsx b/apps/ledger-live-mobile/src/screens/PostOnboarding/PostOnboardingHub.tsx index 884f1d401fca..d649dc96b24a 100644 --- a/apps/ledger-live-mobile/src/screens/PostOnboarding/PostOnboardingHub.tsx +++ b/apps/ledger-live-mobile/src/screens/PostOnboarding/PostOnboardingHub.tsx @@ -117,16 +117,11 @@ const PostOnboardingHub = ({ navigation }: NavigationProps) => { navigation.setOptions({ gestureEnabled: false, headerRight: () => null }); navigation.getParent()?.setOptions({ gestureEnabled: false }); allowClosingScreen.current = false; - const beforeRemoveCallback: EventListenerCallback< - StackNavigationEventMap & - EventMapCore>, - "beforeRemove" - > = e => { + const listenerCleanup = navigation.addListener("beforeRemove", e => { if (!allowClosingScreen.current) e.preventDefault(); - }; - navigation.addListener("beforeRemove", beforeRemoveCallback); + }); return () => { - navigation.removeListener("beforeRemove", beforeRemoveCallback); + listenerCleanup(); clearAnimationTimeout(); cancelAnimation(animDoneValue); };