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; parentID: number;
icon?: string; icon?: string;
wideBanner?: string; wideBanner?: string;
itemCount?: number;
} }

View File

@@ -1,7 +1,6 @@
import { Component, OnInit, signal, computed, ChangeDetectionStrategy } from '@angular/core'; import { Component, OnInit, signal, computed, ChangeDetectionStrategy } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Router, RouterLink } from '@angular/router'; import { Router, RouterLink } from '@angular/router';
import { forkJoin } from 'rxjs';
import { ApiService } from '../../services'; import { ApiService } from '../../services';
import { Category } from '../../models'; import { Category } from '../../models';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
@@ -19,7 +18,6 @@ export class HomeComponent implements OnInit {
brandName = environment.brandFullName; brandName = environment.brandFullName;
isnovo = environment.theme === 'novo'; isnovo = environment.theme === 'novo';
categories = signal<Category[]>([]); categories = signal<Category[]>([]);
itemCounts = signal<Map<number, number>>(new Map());
wideCategories = signal<Set<number>>(new Set()); wideCategories = signal<Set<number>>(new Set());
loading = signal(true); loading = signal(true);
error = signal<string | null>(null); error = signal<string | null>(null);
@@ -55,7 +53,6 @@ export class HomeComponent implements OnInit {
next: (categories) => { next: (categories) => {
this.categories.set(categories); this.categories.set(categories);
this.loading.set(false); this.loading.set(false);
this.loadItemCounts();
this.detectWideImages(categories); this.detectWideImages(categories);
}, },
error: (err) => { 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 { 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[] { getTopLevelCategories(): Category[] {