Skip to content

Commit

Permalink
refactor: remove not needed personalization status checks within effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisie96 committed Aug 21, 2023
1 parent 601cf28 commit 5dad199
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 39 deletions.
10 changes: 2 additions & 8 deletions src/app/core/store/content/pages/pages.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ import { concatMap, map, mergeMap, switchMap } from 'rxjs/operators';
import { CMSService } from 'ish-core/services/cms/cms.service';
import { selectRouteParam } from 'ish-core/store/core/router';
import { setBreadcrumbData } from 'ish-core/store/core/viewconf';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
import {
mapErrorToAction,
mapToPayloadProperty,
useCombinedObservableOnAction,
whenTruthy,
} from 'ish-core/utils/operators';
import { mapErrorToAction, mapToPayloadProperty, whenTruthy } from 'ish-core/utils/operators';

import {
loadContentPage,
Expand All @@ -35,7 +29,7 @@ export class PagesEffects {

loadContentPage$ = createEffect(() =>
this.actions$.pipe(
useCombinedObservableOnAction(this.actions$.pipe(ofType(loadContentPage)), personalizationStatusDetermined),
ofType(loadContentPage),
mapToPayloadProperty('contentPageId'),
mergeMap(contentPageId =>
this.cmsService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cold, hot } from 'jasmine-marbles';
import { Observable, of, throwError } from 'rxjs';
import { instance, mock, when } from 'ts-mockito';

import { FeatureToggleModule } from 'ish-core/feature-toggle.module';
import { FeatureToggleModule, FeatureToggleService } from 'ish-core/feature-toggle.module';
import { ConfigurationService } from 'ish-core/services/configuration/configuration.service';
import { CoreStoreModule } from 'ish-core/store/core/core-store.module';
import { serverConfigError } from 'ish-core/store/core/error';
Expand All @@ -32,6 +32,7 @@ describe('Server Config Effects', () => {
],
providers: [
{ provide: ConfigurationService, useFactory: () => instance(configurationServiceMock) },
{ provide: FeatureToggleService, useFactory: () => instance(mock(FeatureToggleService)) },
provideStoreSnapshots(),
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { ConfigurationService } from 'ish-core/services/configuration/configurat
import { applyConfiguration } from 'ish-core/store/core/configuration';
import { ConfigurationState } from 'ish-core/store/core/configuration/configuration.reducer';
import { serverConfigError } from 'ish-core/store/core/error';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { delayUntil, mapErrorToAction, mapToPayloadProperty, whenFalsy, whenTruthy } from 'ish-core/utils/operators';
import { mapErrorToAction, mapToPayloadProperty, whenFalsy, whenTruthy } from 'ish-core/utils/operators';

import {
loadExtraConfigFail,
Expand Down Expand Up @@ -63,7 +62,6 @@ export class ServerConfigEffects {
takeWhile(() => this.featureToggleService.enabled('extraConfiguration')),
switchMap(() => this.store.pipe(select(isExtraConfigurationLoaded))),
whenFalsy(),
delayUntil(this.actions$.pipe(ofType(personalizationStatusDetermined))),
concatMap(() =>
this.configService.getExtraConfiguration().pipe(
map(extra => loadExtraConfigSuccess({ extra })),
Expand Down
27 changes: 6 additions & 21 deletions src/app/core/store/shopping/categories/categories.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ import { ofCategoryUrl } from 'ish-core/routing/category/category.route';
import { CategoriesService } from 'ish-core/services/categories/categories.service';
import { selectRouteParam } from 'ish-core/store/core/router';
import { setBreadcrumbData } from 'ish-core/store/core/viewconf';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { loadMoreProducts } from 'ish-core/store/shopping/product-listing';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
import { InjectSingle } from 'ish-core/utils/injection';
import {
mapErrorToAction,
mapToPayloadProperty,
useCombinedObservableOnAction,
whenTruthy,
} from 'ish-core/utils/operators';
import { mapErrorToAction, mapToPayloadProperty, whenTruthy } from 'ish-core/utils/operators';

import {
loadCategory,
Expand Down Expand Up @@ -54,11 +48,8 @@ export class CategoriesEffects {
* when the requested {@link Category} is not available, yet
*/
selectedCategory$ = createEffect(() =>
this.actions$.pipe(
useCombinedObservableOnAction(
this.store.pipe(select(selectRouteParam('categoryUniqueId'))),
personalizationStatusDetermined
),
this.store.pipe(
select(selectRouteParam('categoryUniqueId')),
whenTruthy(),
withLatestFrom(this.store.pipe(select(getCategoryEntities))),
filter(([id, entities]) => !CategoryHelper.isCategoryCompletelyLoaded(entities[id])),
Expand All @@ -71,11 +62,8 @@ export class CategoriesEffects {
* when the requested ref in {@link getCategoryRefs} is not available, yet
*/
selectedCategoryRef$ = createEffect(() =>
this.actions$.pipe(
useCombinedObservableOnAction(
this.store.pipe(select(selectRouteParam('categoryRefId'))),
personalizationStatusDetermined
),
this.store.pipe(
select(selectRouteParam('categoryRefId')),
whenTruthy(),
withLatestFrom(this.store.pipe(select(getCategoryRefs)), this.store.pipe(select(getCategoryEntities))),
filter(
Expand Down Expand Up @@ -104,10 +92,7 @@ export class CategoriesEffects {

loadTopLevelCategories$ = createEffect(() =>
this.actions$.pipe(
useCombinedObservableOnAction(
this.actions$.pipe(ofType(loadTopLevelCategories)),
personalizationStatusDetermined
),
ofType(loadTopLevelCategories),
switchMap(() =>
this.categoryService.getTopLevelCategories(this.mainNavigationMaxSubCategoriesDepth).pipe(
map(categories => loadTopLevelCategoriesSuccess({ categories })),
Expand Down
4 changes: 1 addition & 3 deletions src/app/core/store/shopping/filter/filter.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Actions, createEffect, ofType } from '@ngrx/effects';
import { map, mergeMap, switchMap } from 'rxjs/operators';

import { FilterService } from 'ish-core/services/filter/filter.service';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { delayUntil, mapErrorToAction, mapToPayload } from 'ish-core/utils/operators';
import { mapErrorToAction, mapToPayload } from 'ish-core/utils/operators';

import {
applyFilter,
Expand All @@ -24,7 +23,6 @@ export class FilterEffects {
loadAvailableFilters$ = createEffect(() =>
this.actions$.pipe(
ofType(loadFilterForCategory, loadFilterForSearch, loadFilterForMaster),
delayUntil(this.actions$.pipe(ofType(personalizationStatusDetermined))),
map(action => {
switch (action.type) {
case loadFilterForCategory.type:
Expand Down
3 changes: 0 additions & 3 deletions src/app/core/store/shopping/products/products.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import { ofProductUrl } from 'ish-core/routing/product/product.route';
import { ProductsService } from 'ish-core/services/products/products.service';
import { selectRouteParam } from 'ish-core/store/core/router';
import { setBreadcrumbData } from 'ish-core/store/core/viewconf';
import { personalizationStatusDetermined } from 'ish-core/store/customer/user';
import { loadCategory } from 'ish-core/store/shopping/categories';
import { loadProductsForFilter } from 'ish-core/store/shopping/filter';
import { getProductListingItemsPerPage, setProductListingPages } from 'ish-core/store/shopping/product-listing';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
import {
delayUntil,
mapErrorToAction,
mapToPayload,
mapToPayloadProperty,
Expand Down Expand Up @@ -80,7 +78,6 @@ export class ProductsEffects {
loadProduct$ = createEffect(() =>
this.actions$.pipe(
ofType(loadProduct),
delayUntil(this.actions$.pipe(ofType(personalizationStatusDetermined))),
mapToPayloadProperty('sku'),
groupBy(identity),
mergeMap(group$ =>
Expand Down

0 comments on commit 5dad199

Please sign in to comment.