request check removed

This commit is contained in:
sdarbinyan
2026-02-14 20:18:55 +04:00
parent 61f441f6b2
commit 0692cc6360
2 changed files with 3 additions and 25 deletions

View File

@@ -4,4 +4,5 @@ export interface Category {
parentID: number;
icon?: string;
wideBanner?: string;
itemCount?: number;
}

View File

@@ -1,7 +1,6 @@
import { Component, OnInit, signal, computed, ChangeDetectionStrategy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Router, RouterLink } from '@angular/router';
import { forkJoin } from 'rxjs';
import { ApiService } from '../../services';
import { Category } from '../../models';
import { environment } from '../../../environments/environment';
@@ -19,7 +18,6 @@ export class HomeComponent implements OnInit {
brandName = environment.brandFullName;
isnovo = environment.theme === 'novo';
categories = signal<Category[]>([]);
itemCounts = signal<Map<number, number>>(new Map());
wideCategories = signal<Set<number>>(new Set());
loading = signal(true);
error = signal<string | null>(null);
@@ -55,7 +53,6 @@ export class HomeComponent implements OnInit {
next: (categories) => {
this.categories.set(categories);
this.loading.set(false);
this.loadItemCounts();
this.detectWideImages(categories);
},
error: (err) => {
@@ -66,29 +63,9 @@ export class HomeComponent implements OnInit {
});
}
private loadItemCounts(): void {
const topLevel = this.topLevelCategories();
if (topLevel.length === 0) return;
const requests: Record<string, ReturnType<ApiService['getCategoryItems']>> = {};
topLevel.forEach(cat => {
requests[cat.categoryID.toString()] = this.apiService.getCategoryItems(cat.categoryID, 1000);
});
forkJoin(requests).subscribe({
next: (results) => {
const counts = new Map<number, number>();
Object.entries(results).forEach(([id, items]) => {
counts.set(Number(id), items.length);
});
this.itemCounts.set(counts);
},
error: (err) => console.error('Error loading item counts:', err)
});
}
getItemCount(categoryID: number): number {
return this.itemCounts().get(categoryID) || 0;
const cat = this.categories().find(c => c.categoryID === categoryID);
return cat?.itemCount || 0;
}
getTopLevelCategories(): Category[] {