mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix(xtream): streamline serial details initialization and loading logic
This commit is contained in:
1 parent
a8aa289735
commit
0b1e0b0d58
1 file changed
+33
-12
@@ -64,6 +64,7 @@ export class SerialDetailsComponent implements OnInit, OnDestroy {
|
||||
readonly currentPlaylistId = signal('');
|
||||
readonly xtreamDownloadContext =
|
||||
signal<SeasonContainerXtreamDownloadContext | null>(null);
|
||||
private readonly detailsInitDone = signal(false);
|
||||
private lastSaveTime = 0;
|
||||
private unsubscribePositionUpdates: (() => void) | null = null;
|
||||
readonly openingEpisodeId = signal<number | null>(null);
|
||||
@@ -100,6 +101,17 @@ export class SerialDetailsComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const playlistId = this.xtreamStore.currentPlaylist()?.id;
|
||||
const { categoryId, serialId } = this.route.snapshot.params;
|
||||
if (!playlistId || this.detailsInitDone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initializeSerialDetails(playlistId, categoryId, serialId);
|
||||
this.detailsInitDone.set(true);
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
const session = this.externalPlayback.activeSession();
|
||||
const selectedItem = this.selectedItem();
|
||||
@@ -157,19 +169,14 @@ export class SerialDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const currentPlaylist = this.xtreamStore.currentPlaylist();
|
||||
if (!currentPlaylist?.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { categoryId, serialId } = this.route.snapshot.params;
|
||||
this.xtreamStore.fetchSerialDetailsWithMetadata({
|
||||
serialId,
|
||||
categoryId,
|
||||
});
|
||||
this.xtreamStore.checkFavoriteStatus(
|
||||
serialId,
|
||||
this.xtreamStore.currentPlaylist().id
|
||||
);
|
||||
void this.loadSeriesPlaybackPositions(
|
||||
this.xtreamStore.currentPlaylist().id,
|
||||
Number(serialId)
|
||||
);
|
||||
this.initializeSerialDetails(currentPlaylist.id, categoryId, serialId);
|
||||
this.detailsInitDone.set(true);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -323,4 +330,18 @@ export class SerialDetailsComponent implements OnInit, OnDestroy {
|
||||
updated.delete(contentXtreamId);
|
||||
this.episodePlaybackPositions.set(updated);
|
||||
}
|
||||
|
||||
private initializeSerialDetails(
|
||||
playlistId: string,
|
||||
categoryId: string | number,
|
||||
serialId: string
|
||||
): void {
|
||||
this.xtreamStore.fetchSerialDetailsWithMetadata({
|
||||
serialId,
|
||||
categoryId: Number(categoryId),
|
||||
});
|
||||
const serialXtreamId = Number(serialId);
|
||||
this.xtreamStore.checkFavoriteStatus(serialXtreamId, playlistId);
|
||||
void this.loadSeriesPlaybackPositions(playlistId, serialXtreamId);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user