mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix(pwa): filter stalker from xtream collections
This commit is contained in:
1 parent
6438eec49f
commit
87dfaec03d
4 files changed
+67
-2
No files matched your search
+28
@@ -286,6 +286,34 @@ describe('UnifiedFavoritesDataService', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not load Stalker portals through the PWA Xtream global favorites path', async () => {
|
||||
Object.defineProperty(window, 'electron', {
|
||||
value: undefined,
|
||||
configurable: true,
|
||||
});
|
||||
store.select.mockReturnValue(
|
||||
of([
|
||||
{
|
||||
_id: 'xtream-1',
|
||||
title: 'Xtream PWA',
|
||||
serverUrl: 'https://xtream.example.com',
|
||||
},
|
||||
{
|
||||
_id: 'stalker-1',
|
||||
title: 'Stalker Portal',
|
||||
serverUrl: 'https://stalker.example.com',
|
||||
macAddress: '00:11:22:33:44:55',
|
||||
favorites: stalkerFavorites,
|
||||
},
|
||||
] satisfies Partial<PlaylistMeta>[])
|
||||
);
|
||||
|
||||
await service.getFavorites('all');
|
||||
|
||||
expect(xtreamDataSource.getFavorites).toHaveBeenCalledTimes(1);
|
||||
expect(xtreamDataSource.getFavorites).toHaveBeenCalledWith('xtream-1');
|
||||
});
|
||||
|
||||
it('preserves persisted M3U favorites order when extracting playlist favorites', async () => {
|
||||
playlistsService.getPlaylistById.mockReturnValue(
|
||||
of({
|
||||
|
||||
@@ -517,7 +517,9 @@ export class UnifiedFavoritesDataService {
|
||||
if (!window.electron) {
|
||||
const allMeta = await this.getAllMeta();
|
||||
const results: UnifiedCollectionItem[] = [];
|
||||
for (const meta of allMeta.filter((p) => p._id && p.serverUrl)) {
|
||||
for (const meta of allMeta.filter(
|
||||
(p) => p._id && this.isXtreamPlaylist(p)
|
||||
)) {
|
||||
results.push(
|
||||
...(await this.getXtreamPlaylistFavorites(meta._id))
|
||||
);
|
||||
@@ -824,6 +826,12 @@ export class UnifiedFavoritesDataService {
|
||||
}, new Map<string, UnifiedCollectionItem[]>());
|
||||
}
|
||||
|
||||
private isXtreamPlaylist(
|
||||
playlist: Pick<PlaylistMeta, 'serverUrl' | 'macAddress'>
|
||||
): boolean {
|
||||
return Boolean(playlist.serverUrl) && !playlist.macAddress;
|
||||
}
|
||||
|
||||
private getStalkerFavoriteId(
|
||||
favorite:
|
||||
| Pick<UnifiedCollectionItem, 'stalkerId' | 'uid'>
|
||||
|
||||
@@ -398,6 +398,35 @@ describe('UnifiedRecentDataService', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('does not load Stalker portals through the PWA Xtream global recent path', async () => {
|
||||
Object.defineProperty(window, 'electron', {
|
||||
value: undefined,
|
||||
configurable: true,
|
||||
});
|
||||
store.select.mockReturnValue(
|
||||
of([
|
||||
{
|
||||
_id: 'xtream-1',
|
||||
title: 'Xtream PWA',
|
||||
serverUrl: 'https://xtream.example.com',
|
||||
},
|
||||
{
|
||||
_id: 'stalker-1',
|
||||
title: 'Stalker Portal',
|
||||
serverUrl: 'https://stalker.example.com',
|
||||
macAddress: '00:11:22:33:44:55',
|
||||
},
|
||||
] satisfies Partial<PlaylistMeta>[])
|
||||
);
|
||||
|
||||
await service.getRecentItems('all');
|
||||
|
||||
expect(xtreamDataSource.getRecentItems).toHaveBeenCalledTimes(1);
|
||||
expect(xtreamDataSource.getRecentItems).toHaveBeenCalledWith(
|
||||
'xtream-1'
|
||||
);
|
||||
});
|
||||
|
||||
it('clears Xtream recent localStorage during global PWA clear', async () => {
|
||||
Object.defineProperty(window, 'electron', {
|
||||
value: undefined,
|
||||
|
||||
@@ -354,7 +354,7 @@ export class UnifiedRecentDataService {
|
||||
const allMeta = await this.getAllMeta();
|
||||
const results: UnifiedCollectionItem[] = [];
|
||||
for (const meta of allMeta.filter(
|
||||
(playlist) => playlist._id && playlist.serverUrl
|
||||
(playlist) => playlist._id && this.isXtreamPlaylist(playlist)
|
||||
)) {
|
||||
results.push(...(await this.getXtreamPlaylistRecent(meta._id)));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user