diff --git a/src/app/features/website/catalog/containers/catalog-container.component.ts b/src/app/features/website/catalog/containers/catalog-container.component.ts index 40a0aba..8111e2a 100644 --- a/src/app/features/website/catalog/containers/catalog-container.component.ts +++ b/src/app/features/website/catalog/containers/catalog-container.component.ts @@ -15,6 +15,7 @@ import { UserExperienceFacade } from '../../../../facades/platform/user-experien import { CartService } from '../../../../services'; import { LanguageService } from '../../../../services/language.service'; import { PrefetchService } from '../../../../services/prefetch.service'; +import { LocalStorageService } from '../../../../core/storage/local-storage.service'; import { TranslatePipe } from '../../../../i18n/translate.pipe'; import { TranslateService } from '../../../../i18n/translate.service'; import { DEFAULT_CATALOG_CONFIG, DEFAULT_USER_EXPERIENCE_CONFIG } from '../../../../shared/models/config'; @@ -68,6 +69,7 @@ export class CatalogContainerComponent { private readonly shareService = inject(ProductShareService); private readonly notifications = inject(UserNotificationService); private readonly translate = inject(TranslateService); + private readonly storage = inject(LocalStorageService); readonly catalogConfig = signal(this.resolveCatalogConfig()); readonly userExperienceConfig = signal(this.resolveUserExperienceConfig()); @@ -150,7 +152,7 @@ export class CatalogContainerComponent { }); effect(() => { - const saved = typeof localStorage !== 'undefined' ? localStorage.getItem('catalog.layout.preference') : null; + const saved = this.storage.getItem('catalog.layout.preference'); if (!saved) { return; } @@ -521,9 +523,7 @@ export class CatalogContainerComponent { changeLayout(layout: CatalogLayoutMode): void { const normalized = this.normalizeLayout(layout); this.state.update(current => ({ ...current, layout: normalized })); - if (typeof localStorage !== 'undefined') { - localStorage.setItem('catalog.layout.preference', normalized); - } + this.storage.setItem('catalog.layout.preference', normalized); this.syncUrlFromState(); this.persistContinueBrowsing(); } @@ -920,7 +920,7 @@ export class CatalogContainerComponent { } private resolveInitialLayout(): CatalogLayoutMode { - const stored = typeof localStorage !== 'undefined' ? localStorage.getItem('catalog.layout.preference') : null; + const stored = this.storage.getItem('catalog.layout.preference'); return this.normalizeLayout((stored as CatalogLayoutMode) || this.catalogConfig().layout); }