Support new backend contracts: single-flight refresh, ad impression tokens, error handling
- apiFetch: proactive refresh, cross-tab single-flight via Web Locks, no logout on transient errors - AuthContext: save tokens returned on own login change, revoke refresh on logout, sync tabs - Ads: X-Session-Id, impressionToken in impression/click, IAB viewability, safe http(s) targetUrl - STOMP: refresh before CONNECT, stop reconnect loop on dead session, /user/queue/errors behind flag - Auth form: password 8 chars / 72 bytes; 429/413 messages via describeApiError - My posts with auth + moderation badges; post form step validation and field limits - Map: escape user text in Yandex hint/template Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { openExternalUrl } from "../utils/safeUrl";
|
||||
|
||||
const SKIP_DELAY_SECONDS = 5;
|
||||
|
||||
@@ -18,6 +19,26 @@ export default function FullscreenAdOverlay({ ad, onClose }) {
|
||||
const [remaining, setRemaining] = useState(SKIP_DELAY_SECONDS);
|
||||
const [soundOn, setSoundOn] = useState(false);
|
||||
const videoRef = useRef(null);
|
||||
const closeRef = useRef(null);
|
||||
const canClose = remaining <= 0;
|
||||
|
||||
// Фон под оверлеем не скроллится (на iOS иначе «уезжает» лента)
|
||||
useEffect(() => {
|
||||
const prev = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
return () => { document.body.style.overflow = prev; };
|
||||
}, []);
|
||||
|
||||
// Esc закрывает, как только появилась кнопка закрытия; фокус — на неё
|
||||
useEffect(() => {
|
||||
if (!canClose) return;
|
||||
closeRef.current?.focus();
|
||||
const onKey = (e) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
document.addEventListener("keydown", onKey);
|
||||
return () => document.removeEventListener("keydown", onKey);
|
||||
}, [canClose, onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (remaining <= 0) return;
|
||||
@@ -54,9 +75,8 @@ export default function FullscreenAdOverlay({ ad, onClose }) {
|
||||
|
||||
const handleVideoClick = () => {
|
||||
videoRef.current?.play().catch(() => {});
|
||||
if (ad.targetUrl) {
|
||||
window.open(ad.targetUrl, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
// Только абсолютный http(s): targetUrl — данные с сервера
|
||||
openExternalUrl(ad.targetUrl);
|
||||
};
|
||||
|
||||
const handleToggleSound = (e) => {
|
||||
@@ -70,7 +90,7 @@ export default function FullscreenAdOverlay({ ad, onClose }) {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fs-ad-overlay">
|
||||
<div className="fs-ad-overlay" role="dialog" aria-modal="true" aria-label={t('fullscreenAd.label')}>
|
||||
<span className="fs-ad-label">{t('fullscreenAd.label')}</span>
|
||||
<video
|
||||
ref={(node) => {
|
||||
@@ -95,12 +115,13 @@ export default function FullscreenAdOverlay({ ad, onClose }) {
|
||||
>
|
||||
{soundOn ? "🔊" : "🔇"}
|
||||
</button>
|
||||
{remaining > 0 ? (
|
||||
{!canClose ? (
|
||||
<span className="fs-ad-skip-timer">
|
||||
{t('fullscreenAd.closeIn', { seconds: remaining })}
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
ref={closeRef}
|
||||
type="button"
|
||||
className="fs-ad-close"
|
||||
onClick={onClose}
|
||||
|
||||
Reference in New Issue
Block a user