PEP-100: popups blocked — a new-tab link instead of leaving Peppa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bb7b1b4158
commit
60fa861303
@ -14,6 +14,7 @@ export function OpenBotButton({ label, variant = "default", size = "sm" }: { lab
|
||||
const router = useRouter();
|
||||
const [waiting, setWaiting] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [link, setLink] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!waiting) return;
|
||||
@ -35,8 +36,9 @@ export function OpenBotButton({ label, variant = "default", size = "sm" }: { lab
|
||||
setError(r.error ?? "Не получилось открыть бота");
|
||||
return;
|
||||
}
|
||||
// Popups blocked: never take Peppa away — show a link that opens in a new tab instead.
|
||||
if (tab) tab.location.href = r.url;
|
||||
else window.location.href = r.url;
|
||||
else setLink(r.url);
|
||||
setWaiting(true);
|
||||
}
|
||||
|
||||
@ -45,6 +47,11 @@ export function OpenBotButton({ label, variant = "default", size = "sm" }: { lab
|
||||
<Button type="button" variant={variant} size={size} onClick={() => void open()}>
|
||||
{label}
|
||||
</Button>
|
||||
{link && (
|
||||
<a href={link} target="_blank" rel="noreferrer" className="text-sm font-medium text-primary underline-offset-2 hover:underline">
|
||||
Браузер не открыл новую вкладку — нажмите здесь, чтобы открыть бота
|
||||
</a>
|
||||
)}
|
||||
{waiting && <span className="text-xs text-muted-foreground">Нажмите Start в Telegram и вернитесь сюда — шаг отметится сам.</span>}
|
||||
{error && <span className="text-xs text-destructive">{error}</span>}
|
||||
</span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user