mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
fix(xtream): avoid pwa data source bootstrap cycle
This commit is contained in:
1 parent
a2d6f8ef1c
commit
958135e6d2
2 files changed
+34
-3
No files matched your search
@@ -2,8 +2,10 @@ import { TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
PLAYLIST_DELETE_CLEANUP,
|
||||
PlaylistDeleteCleanup,
|
||||
PlaylistsService,
|
||||
RuntimeCapabilitiesService,
|
||||
} from '@iptvnator/services';
|
||||
import { XtreamApiService } from '../services/xtream-api.service';
|
||||
import {
|
||||
ElectronXtreamDataSource,
|
||||
PwaXtreamDataSource,
|
||||
@@ -65,6 +67,34 @@ describe('provideXtreamDataSource', () => {
|
||||
expect(TestBed.inject(XTREAM_DATA_SOURCE)).toBe(pwaSource);
|
||||
});
|
||||
|
||||
it('does not resolve playlist metadata services while constructing the PWA data source', () => {
|
||||
runtime = {
|
||||
supportsXtreamSqliteDataSource: false,
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
...provideXtreamDataSource(),
|
||||
{
|
||||
provide: RuntimeCapabilitiesService,
|
||||
useValue: runtime,
|
||||
},
|
||||
{
|
||||
provide: XtreamApiService,
|
||||
useValue: {},
|
||||
},
|
||||
{
|
||||
provide: PlaylistsService,
|
||||
useFactory: () => {
|
||||
throw new Error('PlaylistsService should be lazy');
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(() => TestBed.inject(XTREAM_DATA_SOURCE)).not.toThrow();
|
||||
});
|
||||
|
||||
it('skips browser sidecar cleanup for SQLite-backed Xtream storage', async () => {
|
||||
configure(true);
|
||||
const [cleanup] = TestBed.inject(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { inject, Injectable, Injector } from '@angular/core';
|
||||
import {
|
||||
Playlist,
|
||||
PlaybackPositionData,
|
||||
@@ -79,7 +79,7 @@ type StoredXtreamPlaylistData = Omit<XtreamPlaylistData, 'password'> & {
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PwaXtreamDataSource implements IXtreamDataSource {
|
||||
private readonly apiService = inject(XtreamApiService);
|
||||
private readonly playlistsService = inject(PlaylistsService);
|
||||
private readonly injector = inject(Injector);
|
||||
private readonly logger = createLogger('PwaXtreamDataSource');
|
||||
private readonly contentTypes = ['live', 'movie', 'series'] as const;
|
||||
|
||||
@@ -171,8 +171,9 @@ export class PwaXtreamDataSource implements IXtreamDataSource {
|
||||
playlistId: string
|
||||
): Promise<XtreamPlaylistData | null> {
|
||||
try {
|
||||
const playlistsService = this.injector.get(PlaylistsService);
|
||||
const playlist = await firstValueFrom(
|
||||
this.playlistsService.getPlaylistById(playlistId)
|
||||
playlistsService.getPlaylistById(playlistId)
|
||||
);
|
||||
const xtreamPlaylist = this.toXtreamPlaylistData(playlist);
|
||||
|
||||
|
||||
Reference in new issue
Block a user