From ade3861f2ab5722e92b8ffefa76743f5aadd9085 Mon Sep 17 00:00:00 2001 From: Thomas Roberts <5656702+opr@users.noreply.github.com> Date: Tue, 30 May 2023 18:46:18 +0300 Subject: [PATCH] Remove `setFullAddressPushed` to prevent address continually pushing (#9606) * Remove fullShippingAddressPushed action/selectors etc from wc/store/cart * Remove setFullAddressPushed from push-changes --- assets/js/data/cart/actions.ts | 8 -------- assets/js/data/cart/default-state.ts | 1 - assets/js/data/cart/push-changes.ts | 6 ------ assets/js/data/cart/reducers.ts | 9 --------- assets/js/data/cart/resolvers.ts | 5 ----- assets/js/data/cart/selectors.ts | 7 ------- assets/js/types/type-defs/cart.ts | 2 -- 7 files changed, 38 deletions(-) diff --git a/assets/js/data/cart/actions.ts b/assets/js/data/cart/actions.ts index 1f09020e1ff..41b9b8de857 100644 --- a/assets/js/data/cart/actions.ts +++ b/assets/js/data/cart/actions.ts @@ -479,13 +479,6 @@ export const updateCustomerData = } }; -export const setFullShippingAddressPushed = ( - fullShippingAddressPushed: boolean -) => ( { - type: types.SET_FULL_SHIPPING_ADDRESS_PUSHED, - fullShippingAddressPushed, -} ); - type Actions = | typeof addItemToCart | typeof applyCoupon @@ -506,7 +499,6 @@ type Actions = | typeof setShippingAddress | typeof shippingRatesBeingSelected | typeof updateCustomerData - | typeof setFullShippingAddressPushed | typeof updatingCustomerData; export type CartAction = ReturnOrGeneratorYieldUnion< Actions | Thunks >; diff --git a/assets/js/data/cart/default-state.ts b/assets/js/data/cart/default-state.ts index 112f5eeb94f..8ce98387a77 100644 --- a/assets/js/data/cart/default-state.ts +++ b/assets/js/data/cart/default-state.ts @@ -100,7 +100,6 @@ export const defaultCartState: CartState = { applyingCoupon: '', removingCoupon: '', isCartDataStale: false, - fullShippingAddressPushed: false, }, errors: EMPTY_CART_ERRORS, }; diff --git a/assets/js/data/cart/push-changes.ts b/assets/js/data/cart/push-changes.ts index 784a2b12686..a1cabfa3a23 100644 --- a/assets/js/data/cart/push-changes.ts +++ b/assets/js/data/cart/push-changes.ts @@ -20,7 +20,6 @@ import isShallowEqual from '@wordpress/is-shallow-equal'; import { STORE_KEY } from './constants'; import { VALIDATION_STORE_KEY } from '../validation'; import { processErrorResponse } from '../utils'; -import { shippingAddressHasValidationErrors } from './utils'; type CustomerData = { billingAddress: CartBillingAddress; @@ -212,11 +211,6 @@ const updateCustomerData = debounce( (): void => { ) as BaseAddressKey[] ), ]; } - } ) - .finally( () => { - if ( ! shippingAddressHasValidationErrors() ) { - dispatch( STORE_KEY ).setFullShippingAddressPushed( true ); - } } ); } }, 1000 ); diff --git a/assets/js/data/cart/reducers.ts b/assets/js/data/cart/reducers.ts index 3ab809ec8c6..67a9dcfe471 100644 --- a/assets/js/data/cart/reducers.ts +++ b/assets/js/data/cart/reducers.ts @@ -48,15 +48,6 @@ const reducer: Reducer< CartState > = ( action: Partial< CartAction > ) => { switch ( action.type ) { - case types.SET_FULL_SHIPPING_ADDRESS_PUSHED: - state = { - ...state, - metaData: { - ...state.metaData, - fullShippingAddressPushed: action.fullShippingAddressPushed, - }, - }; - break; case types.SET_ERROR_DATA: if ( action.error ) { state = { diff --git a/assets/js/data/cart/resolvers.ts b/assets/js/data/cart/resolvers.ts index 080b021d0db..71b4c386d18 100644 --- a/assets/js/data/cart/resolvers.ts +++ b/assets/js/data/cart/resolvers.ts @@ -9,7 +9,6 @@ import { CartResponse } from '@woocommerce/types'; */ import { CART_API_ERROR } from './constants'; import type { CartDispatchFromMap, CartResolveSelectFromMap } from './index'; -import { shippingAddressHasValidationErrors } from './utils'; /** * Resolver for retrieving all cart data. @@ -28,10 +27,6 @@ export const getCartData = receiveError( CART_API_ERROR ); return; } - - if ( ! shippingAddressHasValidationErrors() ) { - dispatch.setFullShippingAddressPushed( true ); - } receiveCart( cartData ); }; diff --git a/assets/js/data/cart/selectors.ts b/assets/js/data/cart/selectors.ts index 59041eb804e..f4644a4b2d2 100644 --- a/assets/js/data/cart/selectors.ts +++ b/assets/js/data/cart/selectors.ts @@ -222,10 +222,3 @@ export const getItemsPendingQuantityUpdate = ( state: CartState ): string[] => { export const getItemsPendingDelete = ( state: CartState ): string[] => { return state.cartItemsPendingDelete; }; - -/** - * Whether the address has changes that have not been synced with the server. - */ -export const getFullShippingAddressPushed = ( state: CartState ): boolean => { - return state.metaData.fullShippingAddressPushed; -}; diff --git a/assets/js/types/type-defs/cart.ts b/assets/js/types/type-defs/cart.ts index b1fd1cf7b4f..d0ecf0095b8 100644 --- a/assets/js/types/type-defs/cart.ts +++ b/assets/js/types/type-defs/cart.ts @@ -210,8 +210,6 @@ export interface CartMeta { isCartDataStale: boolean; applyingCoupon: string; removingCoupon: string; - /* Whether the full address has been previously pushed to the server */ - fullShippingAddressPushed: boolean; } export interface ExtensionCartUpdateArgs { data: Record< string, unknown >;