fixed image and added priority
This commit is contained in:
@@ -22,7 +22,9 @@ export class HomeComponent implements OnInit {
|
||||
|
||||
// Memoized computed values for performance
|
||||
topLevelCategories = computed(() => {
|
||||
return this.categories().filter(cat => cat.parentID === 0);
|
||||
return this.categories()
|
||||
.filter(cat => cat.parentID === 0)
|
||||
.sort((a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity));
|
||||
});
|
||||
|
||||
// Memoized item count lookup
|
||||
@@ -83,8 +85,14 @@ export class HomeComponent implements OnInit {
|
||||
private detectWideImages(categories: Category[]): void {
|
||||
const topLevel = categories.filter(c => c.parentID === 0);
|
||||
topLevel.forEach(cat => {
|
||||
const src = cat.wideBanner || null;
|
||||
if (!src) return;
|
||||
if (!cat.wideBanner) return;
|
||||
|
||||
// API may send wideBanner as a boolean flag instead of a URL
|
||||
if (cat.wideBanner === true) {
|
||||
this.wideCategories.update(set => { const next = new Set(set); next.add(cat.categoryID); return next; });
|
||||
return;
|
||||
}
|
||||
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
const ratio = img.naturalWidth / img.naturalHeight;
|
||||
@@ -96,7 +104,7 @@ export class HomeComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
};
|
||||
img.src = src;
|
||||
img.src = cat.wideBanner as string;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user