diff --git a/apps/web/src/app/xtream-tauri/category-management-dialog/category-management-dialog.component.scss b/apps/web/src/app/xtream-tauri/category-management-dialog/category-management-dialog.component.scss index 079ba4d9f..caba6ebe6 100644 --- a/apps/web/src/app/xtream-tauri/category-management-dialog/category-management-dialog.component.scss +++ b/apps/web/src/app/xtream-tauri/category-management-dialog/category-management-dialog.component.scss @@ -1,3 +1,7 @@ +::ng-deep .mat-mdc-dialog-content { + overflow: hidden !important; +} + .loading-container { display: flex; flex-direction: column; diff --git a/apps/web/src/app/xtream-tauri/category-view/category-view.component.html b/apps/web/src/app/xtream-tauri/category-view/category-view.component.html index 8a2bca02d..c94586314 100644 --- a/apps/web/src/app/xtream-tauri/category-view/category-view.component.html +++ b/apps/web/src/app/xtream-tauri/category-view/category-view.component.html @@ -9,6 +9,7 @@ {{ item.category_name || $any(item).name || 'No category name' }} + ({{ getItemCount(item) }}) } @empty { (); + readonly itemCounts = input>(new Map()); readonly categoryClicked = output(); @@ -31,4 +32,9 @@ export class CategoryViewComponent { String(selectedCategory) === String(itemId) ); } + + getItemCount(item: XtreamCategory): number { + const itemId = Number((item as any).category_id ?? item.id); + return this.itemCounts().get(itemId) ?? 0; + } } diff --git a/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.html b/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.html index 049187809..cee63ce9c 100644 --- a/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.html +++ b/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.html @@ -28,6 +28,7 @@ } @else { } diff --git a/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.ts b/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.ts index 63cecfd15..c899b7931 100644 --- a/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.ts +++ b/apps/web/src/app/xtream-tauri/live-stream-layout/live-stream-layout.component.ts @@ -55,6 +55,7 @@ export class LiveStreamLayoutComponent implements OnInit { private readonly route = inject(ActivatedRoute); readonly categories = this.xtreamStore.getCategoriesBySelectedType; + readonly categoryItemCounts = this.xtreamStore.getCategoryItemCounts; readonly epgItems = this.xtreamStore.epgItems; readonly selectedCategoryId = this.xtreamStore.selectedCategoryId; @@ -75,7 +76,7 @@ export class LiveStreamLayoutComponent implements OnInit { }); } - const { categoryId } = this.route.firstChild.snapshot.params; + const categoryId = this.route.firstChild?.snapshot.params['categoryId']; if (categoryId) this.xtreamStore.setSelectedCategory(Number(categoryId)); } diff --git a/apps/web/src/app/xtream-tauri/xtream-main-container.component.html b/apps/web/src/app/xtream-tauri/xtream-main-container.component.html index 94e1e5054..4b388fd1a 100644 --- a/apps/web/src/app/xtream-tauri/xtream-main-container.component.html +++ b/apps/web/src/app/xtream-tauri/xtream-main-container.component.html @@ -16,6 +16,7 @@ diff --git a/apps/web/src/app/xtream-tauri/xtream-main-container.component.ts b/apps/web/src/app/xtream-tauri/xtream-main-container.component.ts index 847779bff..67e78bd73 100644 --- a/apps/web/src/app/xtream-tauri/xtream-main-container.component.ts +++ b/apps/web/src/app/xtream-tauri/xtream-main-container.component.ts @@ -35,6 +35,7 @@ export class XtreamMainContainerComponent implements OnInit { private readonly dialog = inject(MatDialog); readonly categories = this.xtreamStore.getCategoriesBySelectedType; + readonly categoryItemCounts = this.xtreamStore.getCategoryItemCounts; readonly selectedCategoryId = this.xtreamStore.selectedCategoryId; diff --git a/apps/web/src/app/xtream-tauri/xtream.store.ts b/apps/web/src/app/xtream-tauri/xtream.store.ts index 2ea2b37db..eb7970754 100644 --- a/apps/web/src/app/xtream-tauri/xtream.store.ts +++ b/apps/web/src/app/xtream-tauri/xtream.store.ts @@ -87,6 +87,29 @@ export const XtreamStore = signalStore( ? store.vodCategories() : store.serialCategories(); }), + /** + * Memoized category item counts map. + * Returns a Map for the currently selected content type. + * The Map is recomputed only when streams or content type changes. + */ + getCategoryItemCounts: computed(() => { + const type = store.selectedContentType(); + const streams = + type === 'live' + ? store.liveStreams() + : type === 'vod' + ? store.vodStreams() + : store.serialStreams(); + + const countMap = new Map(); + for (const item of streams) { + const catId = Number(item.category_id); + if (!isNaN(catId)) { + countMap.set(catId, (countMap.get(catId) || 0) + 1); + } + } + return countMap; + }), getSelectedCategory: computed(() => { const categoryId = store.selectedCategoryId(); return [