mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 05:36:17 -08:00
feat(xtream): add favorites list
This commit is contained in:
1 parent
d57fd52ac5
commit
3e008aa3f2
14 files changed
+312
-23
No files matched your search
@@ -14,6 +14,8 @@ import {
|
||||
createFavoritesPlaylist,
|
||||
createPlaylistObject,
|
||||
} from '../../../shared/playlist.utils';
|
||||
import { XtreamItem } from '../../../shared/xtream-item.interface';
|
||||
import { XtreamSerieItem } from '../../../shared/xtream-serie-item.interface';
|
||||
import { DbStores } from '../indexed-db.config';
|
||||
import { PlaylistMeta } from '../shared/playlist-meta.type';
|
||||
|
||||
@@ -118,6 +120,43 @@ export class PlaylistsService {
|
||||
);
|
||||
}
|
||||
|
||||
getPortalFavorites(portalId: string) {
|
||||
return this.dbService
|
||||
.getByID<{ favorites: Partial<XtreamItem>[] }>(
|
||||
DbStores.Playlists,
|
||||
portalId
|
||||
)
|
||||
.pipe(map((item) => item.favorites ?? []));
|
||||
}
|
||||
|
||||
addPortalFavorite(portalId: string, item: any) {
|
||||
return this.getPlaylistById(portalId).pipe(
|
||||
switchMap((portal) =>
|
||||
this.dbService.update(DbStores.Playlists, {
|
||||
...portal,
|
||||
favorites: [...(portal.favorites ?? []), item],
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
removeFromPortalFavorites(portalId: string, favoriteId: number) {
|
||||
return this.getPlaylistById(portalId).pipe(
|
||||
switchMap((portal) =>
|
||||
this.dbService.update(DbStores.Playlists, {
|
||||
...portal,
|
||||
favorites: portal.favorites.filter(
|
||||
(i) =>
|
||||
(i as Partial<XtreamItem>).stream_id !==
|
||||
favoriteId &&
|
||||
(i as Partial<XtreamSerieItem>).series_id !==
|
||||
favoriteId
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
updatePlaylistPositions(
|
||||
positionUpdates: {
|
||||
id: string;
|
||||
|
||||
Reference in new issue
Block a user