mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix(navigation): break BackButton loop on single-tariff /subscriptions/:id deep-link
User flow that hung:
1. Bot deep-link opens MiniApp directly on /subscriptions/:id (idx=0).
2. Telegram shows BackButton.
3. Tap → TelegramBackButton handler sees no in-app history and falls
back to getFallbackParentPath('/subscriptions/:id') = '/subscriptions'.
4. Subscriptions page renders, sees single-tariff + 1 subscription,
<Navigate replace> redirects right back to /subscriptions/:id.
5. BackButton looks dead — taps do nothing visible.
Fix: only redirect when there is in-app history. When idx=0 (deep-link or
just-arrived-via-back), render the list page instead. The user then sees
their single subscription as a card and can tap into it, and the next
BackButton tap exits the MiniApp as expected.
Reported by Серёжа in bugs topic #599679.
This commit is contained in:
@@ -9,6 +9,7 @@ import { getGlassColors } from '../utils/glassTheme';
|
||||
import { useAuthStore } from '../store/auth';
|
||||
import SubscriptionListCard from '../components/subscription/SubscriptionListCard';
|
||||
import TrialOfferCard from '../components/dashboard/TrialOfferCard';
|
||||
import { hasInAppHistory } from '../utils/navigation';
|
||||
|
||||
function EmptyState({ onBuy }: { onBuy: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -106,8 +107,11 @@ export default function Subscriptions() {
|
||||
},
|
||||
});
|
||||
|
||||
// Single-tariff mode with one subscription: skip list, go directly to detail
|
||||
if (data && !isMultiTariff && subscriptions.length === 1) {
|
||||
// Single-tariff mode with one subscription: skip list, go directly to detail.
|
||||
// Skip the redirect when the user just hit the Telegram BackButton from
|
||||
// /subscriptions/:id — that lands us here with idx=0, and redirecting back
|
||||
// to the detail page creates a Back-button loop the user can't escape (#599679).
|
||||
if (data && !isMultiTariff && subscriptions.length === 1 && hasInAppHistory()) {
|
||||
return <Navigate to={`/subscriptions/${subscriptions[0].id}`} replace />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user