From 09b325cc44ab7d4c99229ad3e3339c43953dee8a Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Mon, 18 Dec 2023 09:19:07 -0500 Subject: [PATCH] Only sort the cart after changes --- src/app/cart/cart.component.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/cart/cart.component.js b/src/app/cart/cart.component.js index c0e67f102..ab86526b4 100644 --- a/src/app/cart/cart.component.js +++ b/src/app/cart/cart.component.js @@ -50,9 +50,11 @@ class CartController { const orderByCode = this.cartData?.items?.map(item => item.code) || [] this.cartService.get() .subscribe(data => { - // Sort the incoming cart to match the order of the previous cart, with new items at the top - data.items?.sort((item1, item2) => orderByCode.indexOf(item1.code) - orderByCode.indexOf(item2.code)) - this.cartData = data + if (reload) { + // Sort the incoming cart to match the order of the previous cart, with new items at the top + data.items?.sort((item1, item2) => orderByCode.indexOf(item1.code) - orderByCode.indexOf(item2.code)) + } + this.cartData = data this.setLoadCartVars(reload) }, error => {