From 7bb61ab64c19761f7f3831b7942f4029a4aecc70 Mon Sep 17 00:00:00 2001 From: 4gray Date: Fri, 6 Mar 2026 23:20:57 +0100 Subject: [PATCH] refactor: streamline navigation and layout handling across components - Updated StalkerShellComponent to utilize utility functions for workspace layout detection and portal section resolution. - Refactored StalkerVod utilities to include inline detail state normalization and added tests for new functionality. - Modified workspace context panels to import shared components for better organization. - Enhanced DownloadsComponent to utilize a collection context for managing categories and downloads. - Updated FavoritesComponent to leverage a portal collection shell layout and improved category management. - Refactored RecentlyViewedComponent to use a shared collection shell layout and optimized item filtering. - Improved SearchResultsComponent to utilize query parameter signals for search term handling. - Updated XtreamMainContainer and XtreamShell components to streamline layout detection and section management. --- .../category-view.component.html | 0 .../category-view.component.scss | 2 +- .../category-view/category-view.component.ts | 0 .../favorites-layout.component.ts | 11 +- .../grid-list/grid-list.component.ts | 2 +- apps/web/src/app/shared/components/index.ts | 4 + .../playlist-error-view.component.html | 0 .../playlist-error-view.component.scss | 0 .../playlist-error-view.component.ts | 0 .../portal-collection-shell.component.html | 23 +++ .../portal-collection-shell.component.ts | 50 +++++ .../search-layout.component.html | 142 +++++++------- .../search-layout/search-layout.component.ts | 3 + .../stalker-inline-detail.component.html | 23 +++ .../stalker-inline-detail.component.ts | 47 +++++ .../navigation/portal-rail-links.component.ts | 6 +- .../shared/navigation/portal-rail-links.ts | 15 +- .../navigation/portal-route.utils.spec.ts | 121 ++++++++++++ .../shared/navigation/portal-route.utils.ts | 57 ++++++ .../styles/portal-sidebar.scss} | 0 .../utils/portal-collection-context.spec.ts | 125 ++++++++++++ .../shared/utils/portal-collection-context.ts | 46 +++++ .../utils/portal-collection-items.spec.ts | 138 +++++++++++++ .../shared/utils/portal-collection-items.ts | 96 +++++++++ .../recently-viewed.component.html | 71 +++---- .../recently-viewed.component.ts | 183 +++++++++--------- .../stalker-favorites.component.html | 63 +++--- .../stalker-favorites.component.ts | 152 +++++++-------- .../stalker-live-stream-layout.component.ts | 10 +- .../stalker-main-container.component.ts | 10 +- .../stalker-search.component.html | 115 +++++------ .../stalker-search.component.ts | 44 +++-- .../stalker-shell/stalker-shell.component.ts | 26 ++- .../src/app/stalker/stalker-vod.utils.spec.ts | 59 ++++++ apps/web/src/app/stalker/stalker-vod.utils.ts | 45 +++++ .../workspace-context-panel.component.ts | 4 +- ...space-favorites-context-panel.component.ts | 2 +- .../category-content-view.component.ts | 2 +- .../downloads/downloads.component.ts | 114 +++++------ .../favorites/favorites.component.html | 13 +- .../favorites/favorites.component.ts | 142 ++++++-------- .../live-stream-layout.component.ts | 13 +- .../recently-viewed.component.html | 19 +- .../recently-viewed.component.ts | 150 +++++++------- .../search-results.component.ts | 18 +- .../xtream-main-container.component.ts | 11 +- .../xtream-shell/xtream-shell.component.ts | 28 ++- 47 files changed, 1487 insertions(+), 718 deletions(-) rename apps/web/src/app/{xtream-electron => shared/components}/category-view/category-view.component.html (100%) rename apps/web/src/app/{xtream-electron => shared/components}/category-view/category-view.component.scss (97%) rename apps/web/src/app/{xtream-electron => shared/components}/category-view/category-view.component.ts (100%) rename apps/web/src/app/{xtream-electron => shared/components}/playlist-error-view/playlist-error-view.component.html (100%) rename apps/web/src/app/{xtream-electron => shared/components}/playlist-error-view/playlist-error-view.component.scss (100%) rename apps/web/src/app/{xtream-electron => shared/components}/playlist-error-view/playlist-error-view.component.ts (100%) create mode 100644 apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.html create mode 100644 apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.ts create mode 100644 apps/web/src/app/shared/components/stalker-inline-detail/stalker-inline-detail.component.html create mode 100644 apps/web/src/app/shared/components/stalker-inline-detail/stalker-inline-detail.component.ts create mode 100644 apps/web/src/app/shared/navigation/portal-route.utils.spec.ts create mode 100644 apps/web/src/app/shared/navigation/portal-route.utils.ts rename apps/web/src/app/{xtream-electron/sidebar.scss => shared/styles/portal-sidebar.scss} (100%) create mode 100644 apps/web/src/app/shared/utils/portal-collection-context.spec.ts create mode 100644 apps/web/src/app/shared/utils/portal-collection-context.ts create mode 100644 apps/web/src/app/shared/utils/portal-collection-items.spec.ts create mode 100644 apps/web/src/app/shared/utils/portal-collection-items.ts diff --git a/apps/web/src/app/xtream-electron/category-view/category-view.component.html b/apps/web/src/app/shared/components/category-view/category-view.component.html similarity index 100% rename from apps/web/src/app/xtream-electron/category-view/category-view.component.html rename to apps/web/src/app/shared/components/category-view/category-view.component.html diff --git a/apps/web/src/app/xtream-electron/category-view/category-view.component.scss b/apps/web/src/app/shared/components/category-view/category-view.component.scss similarity index 97% rename from apps/web/src/app/xtream-electron/category-view/category-view.component.scss rename to apps/web/src/app/shared/components/category-view/category-view.component.scss index 0cb90197d..48653101b 100644 --- a/apps/web/src/app/xtream-electron/category-view/category-view.component.scss +++ b/apps/web/src/app/shared/components/category-view/category-view.component.scss @@ -1,4 +1,4 @@ -@use '../../../nav-list.scss'; +@use '../../../../nav-list.scss'; :host { display: block; diff --git a/apps/web/src/app/xtream-electron/category-view/category-view.component.ts b/apps/web/src/app/shared/components/category-view/category-view.component.ts similarity index 100% rename from apps/web/src/app/xtream-electron/category-view/category-view.component.ts rename to apps/web/src/app/shared/components/category-view/category-view.component.ts diff --git a/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.ts b/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.ts index 78fd1ca16..c009a4fd5 100644 --- a/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.ts +++ b/apps/web/src/app/shared/components/favorites-layout/favorites-layout.component.ts @@ -5,7 +5,8 @@ import { MatTooltip } from '@angular/material/tooltip'; import { ActivatedRoute } from '@angular/router'; import { TranslatePipe } from '@ngx-translate/core'; import { PlaylistSwitcherComponent, ResizableDirective } from 'components'; -import { CategoryViewComponent } from '../../../xtream-electron/category-view/category-view.component'; +import { isWorkspaceLayoutRoute } from '../../navigation/portal-route.utils'; +import { CategoryViewComponent } from '../category-view/category-view.component'; import { ContentCardComponent } from '../content-card/content-card.component'; @Component({ @@ -13,7 +14,7 @@ import { ContentCardComponent } from '../content-card/content-card.component'; templateUrl: './favorites-layout.component.html', styleUrls: [ './favorites-layout.component.scss', - '../../../xtream-electron/sidebar.scss', + '../../styles/portal-sidebar.scss', ], imports: [ CategoryViewComponent, @@ -27,9 +28,9 @@ import { ContentCardComponent } from '../content-card/content-card.component'; ], }) export class FavoritesLayoutComponent { - private readonly route = inject(ActivatedRoute); - readonly isWorkspaceLayout = - this.route.snapshot.data['layout'] === 'workspace'; + readonly isWorkspaceLayout = isWorkspaceLayoutRoute( + inject(ActivatedRoute) + ); readonly categories = input([]); readonly favorites = input([]); diff --git a/apps/web/src/app/shared/components/grid-list/grid-list.component.ts b/apps/web/src/app/shared/components/grid-list/grid-list.component.ts index bee34aefd..10624d7d9 100644 --- a/apps/web/src/app/shared/components/grid-list/grid-list.component.ts +++ b/apps/web/src/app/shared/components/grid-list/grid-list.component.ts @@ -4,7 +4,7 @@ import { MatIcon } from '@angular/material/icon'; import { MatPaginatorModule, PageEvent } from '@angular/material/paginator'; import { MatTooltip } from '@angular/material/tooltip'; import { TranslatePipe } from '@ngx-translate/core'; -import { PlaylistErrorViewComponent } from '../../../xtream-electron/playlist-error-view/playlist-error-view.component'; +import { PlaylistErrorViewComponent } from '../playlist-error-view/playlist-error-view.component'; import { ProgressCapsuleComponent } from '../../../xtream-electron/shared/progress-capsule/progress-capsule.component'; import { WatchedBadgeComponent } from '../../../xtream-electron/shared/watched-badge/watched-badge.component'; diff --git a/apps/web/src/app/shared/components/index.ts b/apps/web/src/app/shared/components/index.ts index e5775eb61..df35b0ed3 100644 --- a/apps/web/src/app/shared/components/index.ts +++ b/apps/web/src/app/shared/components/index.ts @@ -1,2 +1,6 @@ export * from './content-card/content-card.component'; +export * from './category-view/category-view.component'; export * from './header/header.component'; +export * from './playlist-error-view/playlist-error-view.component'; +export * from './portal-collection-shell/portal-collection-shell.component'; +export * from './stalker-inline-detail/stalker-inline-detail.component'; diff --git a/apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.html b/apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.html similarity index 100% rename from apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.html rename to apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.html diff --git a/apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.scss b/apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.scss similarity index 100% rename from apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.scss rename to apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.scss diff --git a/apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.ts b/apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.ts similarity index 100% rename from apps/web/src/app/xtream-electron/playlist-error-view/playlist-error-view.component.ts rename to apps/web/src/app/shared/components/playlist-error-view/playlist-error-view.component.ts diff --git a/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.html b/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.html new file mode 100644 index 000000000..386409629 --- /dev/null +++ b/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.html @@ -0,0 +1,23 @@ +@if (showDetails()) { + +} @else { + +} diff --git a/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.ts b/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.ts new file mode 100644 index 000000000..cbe8bf844 --- /dev/null +++ b/apps/web/src/app/shared/components/portal-collection-shell/portal-collection-shell.component.ts @@ -0,0 +1,50 @@ +import { ChangeDetectionStrategy, Component, input, output } from '@angular/core'; +import { XtreamCategory } from 'shared-interfaces'; +import { FavoritesLayoutComponent } from '../favorites-layout/favorites-layout.component'; + +export interface PortalCollectionShellLayout { + titleTranslationKey?: string; + removeTooltip?: string; + emptyIcon?: string; + showHeaderAction?: boolean; + headerActionIcon?: string; + headerActionTooltip?: string; +} + +@Component({ + selector: 'app-portal-collection-shell', + imports: [FavoritesLayoutComponent], + templateUrl: './portal-collection-shell.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + styles: [ + ` + :host { + display: block; + height: 100%; + width: 100%; + } + `, + ], +}) +export class PortalCollectionShellComponent { + readonly categories = input([]); + readonly items = input([]); + readonly playlistSubtitle = input(''); + readonly playlistTitle = input('Playlist'); + readonly selectedCategoryId = input('all'); + readonly layout = input({}); + readonly showDetails = input(false); + + readonly categoryClicked = output(); + readonly removeItem = output(); + readonly openItem = output(); + readonly headerActionClicked = output(); + + onCategoryClicked(event: { category_id?: string }) { + if (!event?.category_id) { + return; + } + + this.categoryClicked.emit(event.category_id); + } +} diff --git a/apps/web/src/app/shared/components/search-layout/search-layout.component.html b/apps/web/src/app/shared/components/search-layout/search-layout.component.html index f24589d2c..25b0a9547 100644 --- a/apps/web/src/app/shared/components/search-layout/search-layout.component.html +++ b/apps/web/src/app/shared/components/search-layout/search-layout.component.html @@ -2,83 +2,85 @@ -
-