feat(carousel): enhance image loading strategy and improve product display in carousel

This commit is contained in:
2026-07-23 14:44:52 -03:00
parent b04c33bbff
commit 67702ffdd7
8 changed files with 127 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
class="store-home__main-carousel"
[images]="mainCarouselImages"
ariaLabel="Imágenes destacadas de la tienda"
(firstImageReady)="mainCarouselReady.set(true)"
/>
}
}
@@ -31,6 +32,7 @@
[groupLayout]="group.group_layout"
[items]="group.items"
[loading]="isGroupLoading(group.id)"
[loadImages]="!hasMainCarouselImages() || mainCarouselReady()"
(buy)="onBuyProduct($event)"
(addToCart)="onAddToCart($event)"
(pageChange)="onPageChange(group.id, $event)"

View File

@@ -176,7 +176,14 @@ describe('StoreHomePageComponent', () => {
expect(element.firstElementChild).toBe(carousel);
expect(images).toHaveLength(2);
expect(images?.[0].getAttribute('src')).toBe(mainCarouselImages[0]);
expect(images?.[1].getAttribute('src')).toBeNull();
expect(element.querySelectorAll('app-product-column-with-image img')).toHaveLength(0);
images?.[0].dispatchEvent(new Event('load'));
fixture.detectChanges();
expect(images?.[1].getAttribute('src')).toBe(mainCarouselImages[1]);
expect(element.querySelectorAll('app-product-column-with-image img')).toHaveLength(1);
fixture.destroy();
});

View File

@@ -3,6 +3,7 @@ import {
Component,
OnDestroy,
OnInit,
computed,
inject,
signal,
} from '@angular/core';
@@ -53,6 +54,10 @@ export class StoreHomePageComponent implements OnInit, OnDestroy {
protected readonly loading = signal(false);
protected readonly loadingGroupIds = signal<ReadonlySet<number>>(new Set());
protected readonly error = signal<string | null>(null);
protected readonly mainCarouselReady = signal(false);
protected readonly hasMainCarouselImages = computed(
() => (this.tenant()?.main_carousel_images?.length ?? 0) > 0,
);
private catalogRequestSubscription: Subscription | null = null;
private readonly groupRequestSubscriptions = new Map<number, Subscription>();