mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
feat: refactor recent metadata handling for series content in Stalker player and recent features
This commit is contained in:
1 parent
12eca90e4a
commit
2e92629154
2 files changed
+39
-11
No files matched your search
+19
-1
@@ -62,6 +62,21 @@ export function withStalkerPlayer() {
|
||||
const normalized = String(value ?? '').trim();
|
||||
return normalized || fallback;
|
||||
};
|
||||
const getSeriesRecentMetadata = (
|
||||
selectedContentType: StalkerContentType
|
||||
): {
|
||||
category_id?: 'series';
|
||||
is_series?: true;
|
||||
} => {
|
||||
if (selectedContentType !== 'series') {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
category_id: 'series',
|
||||
is_series: true,
|
||||
};
|
||||
};
|
||||
return signalStoreFeature(
|
||||
withMethods(
|
||||
(
|
||||
@@ -399,6 +414,8 @@ export function withStalkerPlayer() {
|
||||
) => {
|
||||
const playlistId = storeState.currentPlaylist()?._id;
|
||||
if (!playlistId) return;
|
||||
const selectedContentType =
|
||||
storeState.selectedContentType();
|
||||
const recentlyViewedItem: {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -410,8 +427,9 @@ export function withStalkerPlayer() {
|
||||
title,
|
||||
category_id: resolveCategoryId(
|
||||
item.category_id,
|
||||
storeState.selectedContentType()
|
||||
selectedContentType
|
||||
),
|
||||
...getSeriesRecentMetadata(selectedContentType),
|
||||
added_at: Date.now(),
|
||||
};
|
||||
playlistService
|
||||
|
||||
+20
-10
@@ -16,14 +16,25 @@ type RecentlyViewedPayload = StalkerPortalItem & {
|
||||
title?: string;
|
||||
};
|
||||
|
||||
function resolveCategoryId(
|
||||
value: unknown,
|
||||
fallback: string
|
||||
): string {
|
||||
function resolveCategoryId(value: unknown, fallback: string): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
return normalized || fallback;
|
||||
}
|
||||
|
||||
function getSeriesRecentMetadata(selectedContentType: string): {
|
||||
category_id?: 'series';
|
||||
is_series?: true;
|
||||
} {
|
||||
if (selectedContentType !== 'series') {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
category_id: 'series',
|
||||
is_series: true,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Recently-viewed concern methods.
|
||||
*/
|
||||
@@ -41,19 +52,18 @@ export function withStalkerRecent() {
|
||||
return {
|
||||
addToRecentlyViewed(item: RecentlyViewedPayload) {
|
||||
const portalId = storeContext.currentPlaylist()?._id;
|
||||
const selectedContentType =
|
||||
storeContext.selectedContentType();
|
||||
const recentItem = {
|
||||
...item,
|
||||
category_id: resolveCategoryId(
|
||||
item.category_id,
|
||||
storeContext.selectedContentType()
|
||||
selectedContentType
|
||||
),
|
||||
...getSeriesRecentMetadata(selectedContentType),
|
||||
added_at: Date.now(),
|
||||
id: item.id ?? item.stream_id ?? '',
|
||||
title:
|
||||
item.title ??
|
||||
item.name ??
|
||||
item.o_name ??
|
||||
'',
|
||||
title: item.title ?? item.name ?? item.o_name ?? '',
|
||||
};
|
||||
playlistService
|
||||
.addPortalRecentlyViewed(portalId, recentItem)
|
||||
|
||||
Reference in new issue
Block a user