diff --git a/apps/electron-backend-e2e/src/xtream-epg.e2e.ts b/apps/electron-backend-e2e/src/xtream-epg.e2e.ts index 000d74894..6d2fb6506 100644 --- a/apps/electron-backend-e2e/src/xtream-epg.e2e.ts +++ b/apps/electron-backend-e2e/src/xtream-epg.e2e.ts @@ -12,7 +12,6 @@ import { } from './electron-test-fixtures'; import { fetchXtreamEpgFixture, - XtreamEpgFixture, XtreamNormalizedEpgListing, } from './portal-mock-fixtures'; @@ -87,7 +86,7 @@ for (const timeZone of ['UTC', 'Europe/Berlin'] as const) { }); const currentDateKey = formatDateKeyInZone(Date.now(), timeZone); - const currentDayTitles = visibleTitlesForCurrentDate( + const currentDayTitles = titlesForDate( fixture.fullEpg, currentDateKey, timeZone @@ -184,22 +183,6 @@ function titlesForDate( .map((listing) => listing.title); } -function visibleTitlesForCurrentDate( - listings: XtreamNormalizedEpgListing[], - currentDateKey: string, - timeZone: string -): string[] { - const nowSeconds = Math.floor(Date.now() / 1000); - - return listings - .filter( - (listing) => - formatDateKeyInZone(listing.startTimestamp * 1000, timeZone) === - currentDateKey && listing.stopTimestamp >= nowSeconds - ) - .map((listing) => listing.title); -} - function getFirstFutureDateKey( listings: XtreamNormalizedEpgListing[], currentDateKey: string, diff --git a/apps/web/src/app/settings/settings-options.spec.ts b/apps/web/src/app/settings/settings-options.spec.ts index 7ac76cf97..856d0566d 100644 --- a/apps/web/src/app/settings/settings-options.spec.ts +++ b/apps/web/src/app/settings/settings-options.spec.ts @@ -44,24 +44,34 @@ describe('buildSettingsSectionNavItems', () => { return ids; } - it('exposes desktop-only items only when isDesktop is true', () => { - const desktopItems = buildSettingsSectionNavItems(true); - const pwaItems = buildSettingsSectionNavItems(false); + it('exposes feature-specific items only when their runtime capabilities are supported', () => { + const supportedItems = buildSettingsSectionNavItems({ + supportsEpg: true, + supportsRemoteControl: true, + }); + const unsupportedItems = buildSettingsSectionNavItems({ + supportsEpg: false, + supportsRemoteControl: false, + }); - expect(desktopItems.map((item) => item.id)).toEqual( + expect(supportedItems.map((item) => item.id)).toEqual( expect.arrayContaining(['epg', 'remote-control']) ); - expect(pwaItems.find((item) => item.id === 'epg')?.visible).toBe( - false - ); expect( - pwaItems.find((item) => item.id === 'remote-control')?.visible + unsupportedItems.find((item) => item.id === 'epg')?.visible + ).toBe(false); + expect( + unsupportedItems.find((item) => item.id === 'remote-control') + ?.visible ).toBe(false); }); it('every nav id matches an existing section template id (regression: remote-control nav no longer maps to the Nx lib name)', () => { const navIds = new Set( - buildSettingsSectionNavItems(true).map((item) => item.id) + buildSettingsSectionNavItems({ + supportsEpg: true, + supportsRemoteControl: true, + }).map((item) => item.id) ); const templateIds = collectSectionTemplateIds(); diff --git a/apps/web/src/app/settings/settings-options.ts b/apps/web/src/app/settings/settings-options.ts index 93e8bb84d..a2275a994 100644 --- a/apps/web/src/app/settings/settings-options.ts +++ b/apps/web/src/app/settings/settings-options.ts @@ -85,9 +85,15 @@ export const SETTINGS_EMBEDDED_PLAYER_OPTIONS: SettingsPlayerOption[] = [ }, ]; -export function buildSettingsSectionNavItems( - isDesktop: boolean -): SettingsSection[] { +export interface SettingsSectionVisibility { + supportsEpg: boolean; + supportsRemoteControl: boolean; +} + +export function buildSettingsSectionNavItems({ + supportsEpg, + supportsRemoteControl, +}: SettingsSectionVisibility): SettingsSection[] { return [ { id: 'general', @@ -105,7 +111,7 @@ export function buildSettingsSectionNavItems( id: 'epg', label: 'SETTINGS.NAV_EPG', icon: 'calendar_month', - visible: isDesktop, + visible: supportsEpg, }, { // Must match the section's HTML id (`remote-control`) so the @@ -116,7 +122,7 @@ export function buildSettingsSectionNavItems( id: 'remote-control', label: 'SETTINGS.NAV_REMOTE', icon: 'smartphone', - visible: isDesktop, + visible: supportsRemoteControl, }, { id: 'backup', diff --git a/apps/web/src/app/settings/settings-playback-section.component.html b/apps/web/src/app/settings/settings-playback-section.component.html index b3a26a9d7..8b3e15080 100644 --- a/apps/web/src/app/settings/settings-playback-section.component.html +++ b/apps/web/src/app/settings/settings-playback-section.component.html @@ -69,7 +69,7 @@ - @if (isDesktop() && isExternalPlayerSelected()) { + @if (supportsManagedExternalPlayers() && isExternalPlayerSelected()) {