diff --git a/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.html b/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.html index a12776367..53630e466 100644 --- a/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.html +++ b/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.html @@ -1,9 +1,10 @@
@if (isItvCategorySelected) { diff --git a/apps/web/src/app/stalker/stalker-main-container.component.ts b/apps/web/src/app/stalker/stalker-main-container.component.ts index 5396e8223..bfd934a9d 100644 --- a/apps/web/src/app/stalker/stalker-main-container.component.ts +++ b/apps/web/src/app/stalker/stalker-main-container.component.ts @@ -8,6 +8,7 @@ import { ActivatedRoute, Router, RouterOutlet } from '@angular/router'; import { TranslatePipe } from '@ngx-translate/core'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { PlaylistsService } from 'services'; +import { PlaylistSwitcherComponent } from 'components'; import { CategoryViewComponent } from '../xtream-tauri/category-view/category-view.component'; import { PlaylistErrorViewComponent } from '../xtream/playlist-error-view/playlist-error-view.component'; import { StalkerStore } from './stalker.store'; @@ -27,11 +28,11 @@ import { StalkerStore } from './stalker.store'; MatIconButton, MatListModule, MatPaginatorModule, - /* MpvPlayerBarComponent, */ NgxSkeletonLoaderModule, PlaylistErrorViewComponent, - TranslatePipe, + PlaylistSwitcherComponent, RouterOutlet, + TranslatePipe, ], }) export class StalkerMainContainerComponent { @@ -54,6 +55,7 @@ export class StalkerMainContainerComponent { readonly itvChannels = this.stalkerStore.itvChannels; readonly selectedCategoryTitle = this.stalkerStore.getSelectedCategoryName; + readonly currentPlaylist = this.stalkerStore.currentPlaylist; /** categories */ readonly categories = this.stalkerStore.getCategoryResource; diff --git a/apps/web/src/app/stalker/stalker-shell/stalker-shell.component.ts b/apps/web/src/app/stalker/stalker-shell/stalker-shell.component.ts index ca990df87..8a186bc58 100644 --- a/apps/web/src/app/stalker/stalker-shell/stalker-shell.component.ts +++ b/apps/web/src/app/stalker/stalker-shell/stalker-shell.component.ts @@ -1,8 +1,9 @@ import { Component, effect, inject, OnDestroy } from '@angular/core'; +import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; import { ActivatedRoute, Router, RouterOutlet } from '@angular/router'; import { Store } from '@ngrx/store'; -import { PlaylistActions } from 'm3u-state'; -import { selectPlaylistById } from 'm3u-state'; +import { PlaylistActions, selectPlaylistById } from 'm3u-state'; +import { map, switchMap } from 'rxjs'; import { NavigationComponent } from '../../xtream-tauri/navigation/navigation.component'; import { NavigationItem } from '../../xtream-tauri/navigation/navigation.interface'; import { StalkerStore } from '../stalker.store'; @@ -38,24 +39,34 @@ export class StalkerShellComponent implements OnDestroy { }, ]; - readonly currentPlaylist = this.store.selectSignal( - selectPlaylistById(this.route.snapshot.params.id) + /** Current playlist derived from route params */ + readonly currentPlaylist = toSignal( + this.route.params.pipe( + map((params) => params['id']), + switchMap((id) => this.store.select(selectPlaylistById(id))) + ) ); constructor() { - this.store.dispatch( - PlaylistActions.setCurrentPlaylistId({ - playlistId: this.route.snapshot.params['id'], - }) - ); + // Subscribe to route params to handle switching between playlists + this.route.params.pipe(takeUntilDestroyed()).subscribe((params) => { + const playlistId = params['id']; - const childRoute = this.route.snapshot.firstChild; - const path = childRoute?.url[0]?.path; - const validTypes = ['vod', 'series', 'itv']; - const initialType = validTypes.includes(path) ? (path as any) : 'vod'; + this.store.dispatch( + PlaylistActions.setCurrentPlaylistId({ playlistId }) + ); + + // Reset store state when switching playlists + this.stalkerStore.resetCategories(); + this.stalkerStore.setSelectedCategory(null); + + const childRoute = this.route.snapshot.firstChild; + const path = childRoute?.url[0]?.path; + const validTypes = ['vod', 'series', 'itv']; + const initialType = validTypes.includes(path) ? (path as any) : 'vod'; + this.stalkerStore.setSelectedContentType(initialType); + }); - this.stalkerStore.setSelectedContentType(initialType); - this.stalkerStore.setSelectedCategory(null); effect(() => { this.stalkerStore.setCurrentPlaylist(this.currentPlaylist()); }); diff --git a/apps/web/src/app/xtream-tauri/favorites/favorites.component.html b/apps/web/src/app/xtream-tauri/favorites/favorites.component.html index 2a130d92b..384cedcfa 100644 --- a/apps/web/src/app/xtream-tauri/favorites/favorites.component.html +++ b/apps/web/src/app/xtream-tauri/favorites/favorites.component.html @@ -1,6 +1,8 @@