From 3c2f650c28a7a47b12dcc19197cf1a6dd46f2b03 Mon Sep 17 00:00:00 2001 From: c0mrade Date: Fri, 29 May 2026 11:22:49 +0300 Subject: [PATCH] fix(navigation): break BackButton loop on single-tariff /subscriptions/:id deep-link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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, 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. --- src/pages/Subscriptions.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/Subscriptions.tsx b/src/pages/Subscriptions.tsx index 9fb032f..0b9a0bd 100644 --- a/src/pages/Subscriptions.tsx +++ b/src/pages/Subscriptions.tsx @@ -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 ; }