Skip to content

Commit

Permalink
fix: ensure only one REST call is executed to get eligible shipping/p…
Browse files Browse the repository at this point in the history
…ayment methods on checkout pages
  • Loading branch information
SGrueber committed Aug 2, 2021
1 parent 8e2f66f commit f19434d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { filter, first, map, takeUntil, withLatestFrom } from 'rxjs/operators';
import { filter, first, map, shareReplay, takeUntil, withLatestFrom } from 'rxjs/operators';

import { CheckoutFacade } from 'ish-core/facades/checkout.facade';
import { BasketView } from 'ish-core/models/basket/basket.model';
Expand Down Expand Up @@ -29,7 +29,7 @@ export class CheckoutPaymentPageComponent implements OnInit, OnDestroy {
this.basketError$ = this.checkoutFacade.basketError$;
this.loading$ = this.checkoutFacade.basketLoading$;
this.priceType$ = this.checkoutFacade.priceType$;
this.paymentMethods$ = this.checkoutFacade.eligiblePaymentMethods$();
this.paymentMethods$ = this.checkoutFacade.eligiblePaymentMethods$().pipe(shareReplay(1));

// if there is only one eligible payment method without parameters, assign it automatically to the basket
this.paymentMethods$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { Observable, Subject, combineLatest } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators';
import { shareReplay, take, takeUntil } from 'rxjs/operators';

import { AccountFacade } from 'ish-core/facades/account.facade';
import { CheckoutFacade } from 'ish-core/facades/checkout.facade';
Expand Down Expand Up @@ -34,7 +34,7 @@ export class CheckoutShippingPageComponent implements OnInit, OnDestroy {
this.basket$ = this.checkoutFacade.basket$;
this.loading$ = this.checkoutFacade.basketLoading$;
this.basketError$ = this.checkoutFacade.basketError$;
this.shippingMethods$ = this.checkoutFacade.eligibleShippingMethods$();
this.shippingMethods$ = this.checkoutFacade.eligibleShippingMethods$().pipe(shareReplay(1));
this.isBusinessCustomer$ = this.accountFacade.isBusinessCustomer$;
}

Expand Down

0 comments on commit f19434d

Please sign in to comment.