From 0bd02deb4ff29e786d2344d53e81b25c7c26630c Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 16 Aug 2026 10:07:58 +0200 Subject: [PATCH] fix(portals): label the year chip with the year it navigates to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `facetYear()` reads the first four-digit run so a day-first provider date resolves, but the templates still sliced the first four characters — so `31-03-1999` rendered as `31-0` while the click opened 1999. The label now comes from the same parser as the destination (`yearLabel`), and the informational chip keeps its previous rendering only when no year parses. Co-Authored-By: Claude Fable 5 --- .../discover-facet-navigation.spec.ts | 18 ++++++++++++++++++ .../navigation/discover-facet-navigation.ts | 11 +++++++++++ .../stalker-series-view.component.html | 5 +++-- .../serial-details.component.html | 5 +++-- .../vod-details-route.component.html | 5 +++-- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.spec.ts b/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.spec.ts index 426cfd253..e945d6cd0 100644 --- a/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.spec.ts +++ b/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.spec.ts @@ -78,6 +78,24 @@ describe('createDiscoverFacetNavigation', () => { } }); + it('labels the chip with the year it navigates to', () => { + const discover = create(xtreamMovie); + + // The label and the destination must not disagree: slicing the + // first four characters of a day-first date renders '31-0' + expect(discover.yearLabel('31-03-1999')).toBe('1999'); + expect(discover.yearLabel('1999-03-31')).toBe('1999'); + expect(discover.yearLabel('1976')).toBe('1976'); + }); + + it('has no label for a date stating no usable year', () => { + const discover = create(xtreamMovie); + + expect(discover.yearLabel('0000-00-00')).toBeNull(); + expect(discover.yearLabel('unknown')).toBeNull(); + expect(discover.yearLabel(undefined)).toBeNull(); + }); + it('refuses the year facet when the target cannot be reached', () => { // Hosts return null when enrichment is off, and Discover reads its // results from TMDB — a year chip must not promise an empty page diff --git a/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.ts b/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.ts index c20b1be81..6ebbba42e 100644 --- a/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.ts +++ b/libs/portal/shared/util/src/lib/navigation/discover-facet-navigation.ts @@ -20,6 +20,13 @@ export interface DiscoverFacetTarget { } export interface DiscoverFacetNavigation { + /** + * The year a chip should DISPLAY, so its label and its destination + * cannot disagree — a day-first `31-03-1999` navigates to 1999 and + * must not render as the first four characters. `null` when the date + * states no usable year; the caller then keeps its own rendering. + */ + yearLabel(releaseDate: string | null | undefined): string | null; canOpenYear(releaseDate: string | null | undefined): boolean; openYear(releaseDate: string | null | undefined): void; openGenre(genre: TmdbGenreFacet): void; @@ -76,6 +83,10 @@ export function createDiscoverFacetNavigation( target() !== null && facetYear(releaseDate) !== null; return { + yearLabel(releaseDate) { + const year = facetYear(releaseDate); + return year === null ? null : String(year); + }, canOpenYear, openYear(releaseDate) { const year = facetYear(releaseDate); diff --git a/libs/portal/stalker/feature/src/lib/stalker-series-view/stalker-series-view.component.html b/libs/portal/stalker/feature/src/lib/stalker-series-view/stalker-series-view.component.html index bd2097927..e7aed956f 100644 --- a/libs/portal/stalker/feature/src/lib/stalker-series-view/stalker-series-view.component.html +++ b/libs/portal/stalker/feature/src/lib/stalker-series-view/stalker-series-view.component.html @@ -22,11 +22,12 @@ class="details__tag details__tag--clickable" (click)="discover.openYear(serial.info.releasedate)" > - {{ serial.info.releasedate }} + {{ discover.yearLabel(serial.info.releasedate) }} } @else { {{ - serial.info.releasedate + discover.yearLabel(serial.info.releasedate) ?? + serial.info.releasedate }} } } diff --git a/libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.html b/libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.html index 5e4cbf481..7d6eb43c8 100644 --- a/libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.html +++ b/libs/portal/xtream/feature/src/lib/serial-details/serial-details.component.html @@ -23,11 +23,12 @@ class="details__tag details__tag--clickable" (click)="discover.openYear(info.releaseDate)" > - {{ info.releaseDate | slice: 0 : 4 }} + {{ discover.yearLabel(info.releaseDate) }} } @else { {{ - info.releaseDate | slice: 0 : 4 + discover.yearLabel(info.releaseDate) ?? + (info.releaseDate | slice: 0 : 4) }} } } diff --git a/libs/portal/xtream/feature/src/lib/vod-details/vod-details-route.component.html b/libs/portal/xtream/feature/src/lib/vod-details/vod-details-route.component.html index 9718aa4e4..407855726 100644 --- a/libs/portal/xtream/feature/src/lib/vod-details/vod-details-route.component.html +++ b/libs/portal/xtream/feature/src/lib/vod-details/vod-details-route.component.html @@ -301,11 +301,12 @@ class="details__tag details__tag--clickable" (click)="discover.openYear(info.releasedate)" > - {{ info.releasedate | slice: 0 : 4 }} + {{ discover.yearLabel(info.releasedate) }} } @else { {{ - info.releasedate | slice: 0 : 4 + discover.yearLabel(info.releasedate) ?? + (info.releasedate | slice: 0 : 4) }} } }