From b22b6f05f17c6eb8756228c3d97445adf8516b3a Mon Sep 17 00:00:00 2001 From: ShivaniKhaire Date: Mon, 5 Oct 2026 14:26:52 +0530 Subject: [PATCH] fix(subscription): redirect back navigation to modules library after unlock (#12) --- app.json | 5 ++++- src/app/subscription/index.tsx | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index 282b9d1..b9e1873 100644 --- a/app.json +++ b/app.json @@ -5,7 +5,10 @@ "version": "1.0.0", "orientation": "portrait", "icon": "./assets/images/icon.png", - "scheme": "myapp", + "scheme": [ + "myapp", + "acupedia" + ], "userInterfaceStyle": "automatic", "ios": { "bundleIdentifier": "com.renownent.mobile.acupedia", diff --git a/src/app/subscription/index.tsx b/src/app/subscription/index.tsx index 3e90f1e..17d885c 100644 --- a/src/app/subscription/index.tsx +++ b/src/app/subscription/index.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useMemo, useState } from "react"; import { Alert, + BackHandler, Linking, Platform, ScrollView, @@ -81,6 +82,30 @@ export default function SubscriptionScreen() { }, [accessToken, refreshAccess]), ); + const handleBack = useCallback(() => { + if (unlocked) { + router.replace("/modules"); + return true; + } + if (router.canGoBack()) { + router.back(); + } else { + router.replace("/modules"); + } + return true; + }, [unlocked]); + + useFocusEffect( + useCallback(() => { + const onBackPress = () => handleBack(); + const subscription = BackHandler.addEventListener( + "hardwareBackPress", + onBackPress + ); + return () => subscription.remove(); + }, [handleBack]) + ); + const showAlert = (alertTitle: string, message: string, onConfirm?: () => void) => { if (Platform.OS === "web") { alert(`${alertTitle}\n\n${message}`); @@ -132,9 +157,11 @@ export default function SubscriptionScreen() { router.back()} + onPress={handleBack} style={styles.backButton} hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }} + accessibilityRole="button" + accessibilityLabel="Go back" >