fix(03-04): Telegram LocationManager deep-link — LOCATION SETTINGS CTA on denied cards + locationManagerUpdated chain re-run

This commit is contained in:
araharah-executor
2026-10-23 01:06:52 +08:00
parent fff865f6cd
commit 9fa4acb319
3 changed files with 50 additions and 11 deletions
+30 -2
View File
@@ -101,7 +101,14 @@ async function boot(): Promise<void> {
const bootCard1 = buildBootCard(locale, 1);
const bootCard2 = buildBootCard(locale, 2);
const deniedCard = buildDeniedCard(locale, { awaitingPin: false });
const awaitingCard = buildDeniedCard(locale, { awaitingPin: true });
const awaitingCard = buildDeniedCard(
locale,
// Debug round 2: the Telegram-only deep-link. LocationManager presence
// is the whole eligibility test — off-Telegram (Desktop/browser) there
// is nothing for openSettings() to open, and navigator.geolocation
// denial is handled by the OS settings hint copy instead.
{ awaitingPin: true, withLocationSettings: wa?.LocationManager !== undefined },
);
const lostCard = buildSignalLostCard(locale);
const gantryOf = (card: HTMLElement): HTMLElement => {
const el = card.querySelector(".gantry");
@@ -117,7 +124,17 @@ async function boot(): Promise<void> {
// is a second buildDeniedCard instance (03-03 stub note) — wiring only the
// first left TRY AGAIN / ASK VIA CHAT dead on the awaiting-pin card.
const wireDeniedActions = (card: HTMLElement): void => {
const retryButton = card.querySelector(".btn-secondary");
const settingsButton = card.querySelector('[data-role="open-location-settings"]');
if (settingsButton instanceof HTMLButtonElement) {
// Debug round 2: deep-links Telegram's pane where the user re-grants
// location for this bot (the "no way to turn on location" report).
settingsButton.addEventListener("click", () => {
const lm = wa?.LocationManager;
if (lm && typeof lm.openSettings === "function") lm.openSettings();
void runFromSession(); // sheet open OR older client without the API — re-request either way
});
}
const retryButton = card.querySelector(".card-actions .btn-secondary:not([data-role])");
if (retryButton instanceof HTMLButtonElement) {
retryButton.addEventListener("click", () => void runFromSession()); // re-runs from link 1
}
@@ -129,6 +146,17 @@ async function boot(): Promise<void> {
wireDeniedActions(deniedCard);
wireDeniedActions(awaitingCard);
// Debug round 2: after the user grants location from Telegram's sheet
// (opened via openSettings), the client fires locationManagerUpdated —
// re-run the chain immediately instead of waiting for a manual tap.
// The Wire: only live Data events on the wrapper — guard chainInFlight.
if (wa && typeof wa.onEvent === "function" && wa.LocationManager) {
wa.onEvent("locationManagerUpdated", () => {
if (chainInFlight) return;
void runFromSession();
});
}
function showCard(card: HTMLElement | null, register: "center" | "bottom" = "center"): void {
if (card !== null) {
stack.replaceChildren(card);