From faa4e2beb24f2bdd84d9bfe146ddb1de58a37cdb Mon Sep 17 00:00:00 2001 From: 4gray Date: Thu, 16 Apr 2026 21:57:18 +0200 Subject: [PATCH] refactor: update searchContent method to accept flexible parameters and clean up XtreamStore Entire-Checkpoint: c6e522b4276c --- .../stores/features/with-search.feature.ts | 25 ++++++++++-- .../src/lib/stores/xtream.store.ts | 38 +------------------ 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/libs/portal/xtream/data-access/src/lib/stores/features/with-search.feature.ts b/libs/portal/xtream/data-access/src/lib/stores/features/with-search.feature.ts index 953c384ee..46c17fd66 100644 --- a/libs/portal/xtream/data-access/src/lib/stores/features/with-search.feature.ts +++ b/libs/portal/xtream/data-access/src/lib/stores/features/with-search.feature.ts @@ -32,6 +32,12 @@ export interface SearchState { isSearching: boolean; } +type SearchContentParams = { + term: string; + types: string[]; + excludeHidden?: boolean; +}; + /** * Initial search filters */ @@ -76,10 +82,23 @@ export function withSearch() { * Search content within the current playlist */ async searchContent( - searchTerm: string, - types: string[], - excludeHidden?: boolean + searchTermOrParams: string | SearchContentParams, + typesArg?: string[], + excludeHiddenArg?: boolean ): Promise { + const searchTerm = + typeof searchTermOrParams === 'string' + ? searchTermOrParams + : searchTermOrParams.term; + const types = + typeof searchTermOrParams === 'string' + ? (typesArg ?? []) + : searchTermOrParams.types; + const excludeHidden = + typeof searchTermOrParams === 'string' + ? excludeHiddenArg + : searchTermOrParams.excludeHidden; + // Access parent store's playlistId (from withPortal) const storeAny = store as ParentSearchStoreLike; const playlistId = storeAny.playlistId?.(); diff --git a/libs/portal/xtream/data-access/src/lib/stores/xtream.store.ts b/libs/portal/xtream/data-access/src/lib/stores/xtream.store.ts index 21b9b3177..52bb775a8 100644 --- a/libs/portal/xtream/data-access/src/lib/stores/xtream.store.ts +++ b/libs/portal/xtream/data-access/src/lib/stores/xtream.store.ts @@ -62,11 +62,6 @@ export const XtreamStore = signalStore( globalRecentItems: computed(() => { return store.recentItems(); }), - - /** - * Alias for importCount for backward compatibility - */ - getImportCount: computed(() => store.importCount()), })), // Cross-feature methods & orchestration @@ -83,19 +78,6 @@ export const XtreamStore = signalStore( return Number(candidateId) === Number(vodId); }); - const searchContent = ( - store as { - searchContent: ( - term: string, - types: string[], - excludeHidden?: boolean - ) => Promise; - } - ).searchContent as ( - term: string, - types: string[], - excludeHidden?: boolean - ) => Promise; return { /** @@ -180,8 +162,7 @@ export const XtreamStore = signalStore( ...vodDetails, stream_id: params.vodId, xtream_id: - catalogItem?.xtream_id ?? - Number(params.vodId), + catalogItem?.xtream_id ?? Number(params.vodId), }); }) .catch((error: unknown) => { @@ -238,23 +219,6 @@ export const XtreamStore = signalStore( store.setIsLoadingDetails(false); }); }, - - /** - * Search content wrapper for rxMethod compatibility - * Can be called with object { term, types, excludeHidden } or direct params - */ - searchContent(params: { - term: string; - types: string[]; - excludeHidden?: boolean; - }): void { - // Call the underlying search method from withSearch - void searchContent( - params.term, - params.types, - params.excludeHidden - ); - }, }; }) );