mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
`setSelectedItem` mirrored every selection's id into `selectedSerialId`, and `serialSeasonsResource` fires a `get_ordered_list&type=series&movie_id=<id>` portal request on every change of that id. Opening any Stalker detail page — plain VOD, vclub items with embedded `series[]` (whose result `mapRegularSeriesSeasons` discards), Ministra `is_series` items, and ITV channel clicks — therefore issued a pointless request, on every entry path (browse, favorites, recent, dashboard, search). Set `selectedSerialId` only when `selectedContentType === 'series'`, clearing it otherwise. The gate is deliberately on content type alone, not item shape: under the `series` content type `serialSeasonsResource` is the only episode source (the detail templates render `<app-stalker-series-view />` with no `vodWithSeries` input, and `isVodSeries()` requires content type `vod`), so gating on `is_series`/`series[]` would leave a series-section item carrying either field with a silently empty episode list. Adds selection-state and request-level regression coverage, and corrects a stale invariant in the Stalker architecture docs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6.3 KiB
6.3 KiB
Stalker Store API Baseline
This is the compatibility baseline for refactoring libs/portal/stalker/data-access/src/lib/stalker.store.ts.
Goal: keep this public surface stable while splitting to feature stores.
Source of Truth
- Store implementation:
libs/portal/stalker/data-access/src/lib/stalker.store.ts - Baseline created on current branch state before feature-store extraction.
Public State Signals
Direct signal properties currently exposed by signalStore:
selectedContentType: 'vod' | 'itv' | 'radio' | 'series'selectedCategoryId: string | null | undefinedselectedVodId: string | undefinedselectedSerialId: string | undefinedselectedItvId: string | undefinedlimit: numberpage: numbersearchPhrase: stringcurrentPlaylist: PlaylistMeta | undefinedtotalCount: numberselectedItem: StalkerVodSource | null | undefinedvodCategories: StalkerCategoryItem[]seriesCategories: StalkerCategoryItem[]itvCategories: StalkerCategoryItem[]radioCategories: StalkerCategoryItem[]hasMoreChannels: booleanitvChannels: StalkerItvChannel[]radioChannels: StalkerItvChannel[]vodSeriesSeasons: StalkerVodSeriesSeason[]vodSeriesEpisodes: StalkerVodSeriesEpisode[]selectedVodSeriesSeasonId: string | undefined
Public Computed Selectors
getTotalPages: numbergetPaginatedContent: StalkerContentItem[]isPaginatedContentLoading: booleanisPaginatedContentFailed: unknowngetSerialSeasonsResource: StalkerSeason[]isSerialSeasonsLoading: booleangetVodSeriesSeasonsResource: StalkerVodSeriesSeason[]isVodSeriesSeasonsLoading: booleangetCategoryResource: StalkerCategoryItem[]isCategoryResourceLoading: booleanisCategoryResourceFailed: unknowngetSelectedCategoryName: string
Exposed Resources/Props
These are currently reachable on the store object and used internally by computed selectors:
getCategoryResource(computed selector with stable array output)categoryResource(internal resource)getContentResource(resource)serialSeasonsResource(resource)vodSeriesSeasonsResource(resource)makeStalkerRequest(...)
During refactor:
- Keep compatibility for external callers that may read these directly.
- If moved/renamed internally, provide facade aliases.
Public Methods (Compatibility Contract)
setSelectedContentType(type: 'vod' | 'itv' | 'radio' | 'series'): voidsetSelectedCategory(id: string | number | null): voidsetSelectedSerialId(id: string): voidsetSelectedVodId(id: string): voidsetSelectedItvId(id: string): voidsetLimit(limit: number): voidsetPage(page: number): voidsetCurrentPlaylist(playlist: PlaylistMeta | undefined): Promise<void>setSelectedItem(selectedItem: StalkerVodSource | null | undefined): voidclearSelectedItem(): voidsetCategories(type: 'vod' | 'series' | 'itv' | 'radio', categories: StalkerCategoryItem[]): voidresetCategories(): voidsetItvChannels(channels: StalkerItvChannel[]): voidsetRadioChannels(channels: StalkerItvChannel[]): voidsetSearchPhrase(phrase: string): voidfetchVodSeriesEpisodes(videoId: string, seasonId: string): Promise<StalkerVodSeriesEpisode[]>getSelectedCategory(): { id: string | number; name: string; type: 'vod' | 'itv' | 'radio' | 'series' }Backed bywithComputedfor compatibility, not bywithMethods.fetchLinkToPlay(portalUrl: string, macAddress: string, cmd: string, series?: number): Promise<string>getExpireDate(): Promise<string>resolveItvPlayback(item: StalkerPortalItem): Promise<ResolvedPortalPlayback>resolveRadioPlayback(item: StalkerPortalItem): Promise<ResolvedPortalPlayback>addToFavorites(item: any, onDone?: () => void): voidremoveFromFavorites(favoriteId: string, onDone?: () => void): voidfetchMovieFileId(movieId: string): Promise<string | null>createLinkToPlayVod(cmd?: string, title?: string, thumbnail?: string, episodeNum?: number, episodeId?: number, startTime?: number): Promise<void>addToRecentlyViewed(item: any): voidremoveFromRecentlyViewed(itemId: number, onComplete?: () => void): voidfetchChannelEpg(channelId: number | string, size?: number): Promise<EpgItem[]>
Current Consumers (Observed)
Top observed store API usage in app code:
currentPlaylist(16 references)setSelectedContentType(9)selectedItem(9)setSelectedItem(7)setSelectedCategory(6)createLinkToPlayVod(6)removeFromFavorites(5)setPage(4)addToFavorites(4)fetchChannelEpg(3)- plus lower-frequency calls for paging/resources/series/recent.
Consumer directories sampled:
libs/portal/stalker/**libs/portal/xtream/feature/**libs/portal/catalog/feature/**libs/ui/components/**
Invariants to Preserve During Refactor
- Selection IDs (
selectedVodId,selectedItvId) are synchronized insetSelectedItem. selectedSerialIdis set only whenselectedContentTypeisseries, and is cleared for every other content type.serialSeasonsResourcefires aget_ordered_list&type=seriesportal request on each change of that id, and it is the only episode source for aseriesselection — while VOD-context shapes (embeddedseries[], Ministrais_series) resolve their episodes elsewhere, so carrying the id there only wastes a request. The gate must stay on content type alone: gating it on item shape would leave a series-section item that happens to carryis_series/series[]with an empty episode list.setSelectedCategory(...)resetspageto0.getPaginatedContent()andgetCategoryResource()always return arrays, even when the underlying request fails.- Radio stores stations separately in
radioChannelsand falls back to a synthetic all-radio category when a portal does not support radio category responses. - Request failures must surface through
isPaginatedContentFailed()andisCategoryResourceFailed()rather than resource reads that throw. createLinkToPlayVod(...)continues to:- support episode playback metadata
- append recently viewed
- preserve external player payload shape
- Full-portal auth path continues through
StalkerSessionService. - Non-auth/simple path continues through
DataService.sendIpcEvent(STALKER_REQUEST, ...). - Resource-driven loading signals preserve existing names.