From d88979e666ee7c5e6a671a283fd0b2a4c775eb29 Mon Sep 17 00:00:00 2001 From: 4gray Date: Wed, 22 Apr 2026 22:24:01 +0200 Subject: [PATCH] feat: enhance global collection route with playlist context and portal type handling --- apps/web/src/app/app.routes.ts | 2 +- .../app/global-collection-route.component.ts | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/app.routes.ts b/apps/web/src/app/app.routes.ts index d4f7d4afd..3f056aa4c 100644 --- a/apps/web/src/app/app.routes.ts +++ b/apps/web/src/app/app.routes.ts @@ -42,7 +42,7 @@ export const routes: Routes = [ canActivate: [dashboardAccessGuard], loadComponent: () => import('workspace-dashboard-feature').then( - (c) => c.WorkspaceDashboardComponent + (c) => c.WorkspaceDashboardRailsComponent ), }, { diff --git a/apps/web/src/app/global-collection-route.component.ts b/apps/web/src/app/global-collection-route.component.ts index 254ec3609..6799a625e 100644 --- a/apps/web/src/app/global-collection-route.component.ts +++ b/apps/web/src/app/global-collection-route.component.ts @@ -1,12 +1,21 @@ -import { ChangeDetectionStrategy, Component, input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'; +import { PlaylistContextFacade } from '@iptvnator/playlist/shared/util'; import { UnifiedCollectionDetailDirective, UnifiedCollectionPageComponent, } from '@iptvnator/portal/shared/ui'; -import { CollectionScope } from '@iptvnator/portal/shared/util'; +import { CollectionScope, PortalProvider } from '@iptvnator/portal/shared/util'; import { StalkerCollectionDetailComponent } from '@iptvnator/portal/stalker/feature'; import { XtreamCollectionDetailComponent } from '@iptvnator/portal/xtream/feature'; +type UnifiedPortalType = 'm3u' | 'xtream' | 'stalker'; + +function providerToPortalType(provider: PortalProvider): UnifiedPortalType { + if (provider === 'playlists') return 'm3u'; + if (provider === 'xtreams') return 'xtream'; + return 'stalker'; +} + @Component({ selector: 'app-global-collection-route', imports: [ @@ -18,7 +27,9 @@ import { XtreamCollectionDetailComponent } from '@iptvnator/portal/xtream/featur template: ` @if (item.sourceType === 'xtream') { @@ -35,6 +46,19 @@ import { XtreamCollectionDetailComponent } from '@iptvnator/portal/xtream/featur changeDetection: ChangeDetectionStrategy.OnPush, }) export class GlobalCollectionRouteComponent { + private readonly playlistContext = inject(PlaylistContextFacade); + readonly mode = input<'favorites' | 'recent'>('favorites'); readonly defaultScope = input(undefined); + + readonly activePlaylistId = computed( + () => this.playlistContext.activePlaylist()?._id ?? null + ); + readonly activePortalType = computed(() => { + const provider = this.playlistContext.activeProvider(); + return provider ? providerToPortalType(provider) : null; + }); + readonly effectiveDefaultScope = computed(() => + this.activePlaylistId() ? 'playlist' : (this.defaultScope() ?? 'all') + ); }