mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-16 22:26:16 -08:00
- 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.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { DestroyRef, Signal, effect, inject } from '@angular/core';
|
|
import { XtreamCategory } from 'shared-interfaces';
|
|
import { FavoritesContextService } from '../../workspace/favorites-context.service';
|
|
|
|
export interface PortalCollectionContextBridge {
|
|
readonly selectedCategoryId: Signal<string>;
|
|
setCategoryId(id: string): void;
|
|
}
|
|
|
|
interface CreatePortalCollectionContextOptions {
|
|
ctx: FavoritesContextService;
|
|
categories: () => XtreamCategory[];
|
|
enabled?: () => boolean;
|
|
}
|
|
|
|
export function createPortalCollectionContext(
|
|
options: CreatePortalCollectionContextOptions
|
|
): PortalCollectionContextBridge {
|
|
const destroyRef = inject(DestroyRef);
|
|
const isEnabled = options.enabled ?? (() => true);
|
|
let managesContext = false;
|
|
|
|
effect(() => {
|
|
if (!isEnabled()) {
|
|
return;
|
|
}
|
|
|
|
managesContext = true;
|
|
options.ctx.setCategories(options.categories());
|
|
});
|
|
|
|
destroyRef.onDestroy(() => {
|
|
if (managesContext && isEnabled()) {
|
|
options.ctx.reset();
|
|
}
|
|
});
|
|
|
|
return {
|
|
selectedCategoryId: options.ctx.selectedCategoryId,
|
|
setCategoryId(id: string): void {
|
|
if (isEnabled()) {
|
|
options.ctx.setCategoryId(id);
|
|
}
|
|
},
|
|
};
|
|
}
|