From cc885c009ae76b8ecadc0e8c57898f5f8e46c29b Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Wed, 15 Jul 2026 03:01:25 +0400 Subject: [PATCH] refactor: route catalog-container localStorage calls through LocalStorageService Sprint 2 high-priority cleanup: layout preference read/write called raw localStorage from a component, violating the no-raw-localStorage rule. Now uses the shared core/storage/LocalStorageService (same as cart/language/location services). Co-Authored-By: Claude Sonnet 5 --- .../catalog/containers/catalog-container.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); }