From e983374dec4cebcbd3a7c22c41fa6e310bf0c459 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Thu, 30 Jul 2026 22:18:09 +0300 Subject: [PATCH] Implement hide breaks feature in AirSchedule component Added a new state to manage the visibility of breaks in the AirSchedule component, allowing users to toggle the display of interstitials and advertisements. Updated the filtering logic to account for this new state, ensuring that the schedule reflects user preferences. Enhanced localization files to include new strings for the hide breaks functionality in both English and Russian. --- .../admin/channels/components/AirSchedule.tsx | 51 +++++++++++++------ frontend/src/shared/lib/locales/en.ts | 1 + frontend/src/shared/lib/locales/ru.ts | 1 + 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/frontend/src/features/admin/channels/components/AirSchedule.tsx b/frontend/src/features/admin/channels/components/AirSchedule.tsx index 6441a99..ce392f0 100644 --- a/frontend/src/features/admin/channels/components/AirSchedule.tsx +++ b/frontend/src/features/admin/channels/components/AirSchedule.tsx @@ -57,6 +57,10 @@ export function AirSchedule({ // По умолчанию прошедшее скрыто: эфир смотрят, чтобы понять, что будет, а вчерашние страницы // приходилось пролистывать каждый раз заново. const [hidePast, setHidePast] = useState(true) + // Врезки тоже скрыты: между двумя сериями их бывает вчетверо больше, чем программ, и лента + // из реклам с заставками перестаёт читаться как программа передач. Снятая галочка показывает + // ленту как есть — ровно то, что уйдёт в эфир. + const [hideBreaks, setHideBreaks] = useState(true) const range = useMemo(() => { const from = dayStartUtc(day, utcOffsetMinutes, dayStartTime) @@ -70,11 +74,15 @@ export function AirSchedule({ const entries = useMemo(() => data ?? [], [data]) const visible = useMemo(() => { - if (!hidePast) return entries - // Идущая запись остаётся: то, что сейчас в эфире, — ещё не история. + // Идущая запись остаётся: то, что сейчас в эфире, — ещё не история. Аварийный запас не врезка + // и не скрывается никогда: он и есть то, ради чего в эту ленту заглядывают. const now = Date.now() - return entries.filter((entry) => new Date(entry.endsAtUtc).getTime() > now) - }, [entries, hidePast]) + return entries.filter( + (entry) => + (!hidePast || new Date(entry.endsAtUtc).getTime() > now) && + (!hideBreaks || (entry.kind !== 'Ad' && entry.kind !== 'Bumper')), + ) + }, [entries, hidePast, hideBreaks]) const totalPages = Math.max(1, Math.ceil(visible.length / PAGE_SIZE)) const pageItems = visible.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE) @@ -106,17 +114,30 @@ export function AirSchedule({ ) })} - +
+ + +
{isLoading ? ( diff --git a/frontend/src/shared/lib/locales/en.ts b/frontend/src/shared/lib/locales/en.ts index db3c0cc..1bb1cdf 100644 --- a/frontend/src/shared/lib/locales/en.ts +++ b/frontend/src/shared/lib/locales/en.ts @@ -783,6 +783,7 @@ export const en = { airToday: 'Today', airCount: 'Entries for the day: {{count}}', airHidePast: 'Hide past entries', + airHideBreaks: 'Hide breaks', }, junctions: { title: 'Junctions', diff --git a/frontend/src/shared/lib/locales/ru.ts b/frontend/src/shared/lib/locales/ru.ts index 9c7eb5d..14826a8 100644 --- a/frontend/src/shared/lib/locales/ru.ts +++ b/frontend/src/shared/lib/locales/ru.ts @@ -778,6 +778,7 @@ export const ru = { airToday: 'Сегодня', airCount: 'Записей за сутки: {{count}}', airHidePast: 'Скрывать прошедшее', + airHideBreaks: 'Скрывать врезки', }, junctions: { title: 'Стыки',