Skip to content

Commit

Permalink
fix: prevent error if language switched on order details page in case…
Browse files Browse the repository at this point in the history
… of ssr
  • Loading branch information
SGrueber committed Nov 16, 2020
1 parent 9a64080 commit 0023025
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/app/core/store/customer/orders/orders.effects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Injectable } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Router } from '@angular/router';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { routerNavigatedAction } from '@ngrx/router-store';
import { Store, select } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { isEqual } from 'lodash-es';
import { race } from 'rxjs';
import { iif, race } from 'rxjs';
import {
concatMap,
distinctUntilChanged,
Expand Down Expand Up @@ -50,6 +51,7 @@ export class OrdersEffects {
private actions$: Actions,
private orderService: OrderService,
private router: Router,
@Inject(PLATFORM_ID) private platformId: string,
private store: Store,
private translateService: TranslateService
) {}
Expand Down Expand Up @@ -163,11 +165,14 @@ export class OrdersEffects {
* Selects and loads an order.
*/
loadOrderForSelectedOrder$ = createEffect(() =>
this.actions$.pipe(
ofType(selectOrder),
mapToPayloadProperty('orderId'),
whenTruthy(),
map(orderId => loadOrder({ orderId }))
iif(
() => isPlatformBrowser(this.platformId),
this.actions$.pipe(
ofType(selectOrder),
mapToPayloadProperty('orderId'),
whenTruthy(),
map(orderId => loadOrder({ orderId }))
)
)
);

Expand Down

0 comments on commit 0023025

Please sign in to comment.