refactor: update searchContent method to accept flexible parameters and clean up XtreamStore

Entire-Checkpoint: c6e522b4276c
This commit is contained in:
4gray committed 2026-04-16 21:57:18 +02:00
1 parent b1c72a7782
commit faa4e2beb2
2 files changed
+23 -40

No files matched your search

@@ -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<XtreamContentItem[]> {
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?.();
@@ -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<unknown>;
}
).searchContent as (
term: string,
types: string[],
excludeHidden?: boolean
) => Promise<unknown>;
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
);
},
};
})
);