Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Remove setFullAddressPushed to prevent address continually pushing (#…
Browse files Browse the repository at this point in the history
…9606)

* Remove fullShippingAddressPushed action/selectors etc from wc/store/cart

* Remove setFullAddressPushed from push-changes
  • Loading branch information
opr authored May 30, 2023
1 parent e7ec80c commit ade3861
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 38 deletions.
8 changes: 0 additions & 8 deletions assets/js/data/cart/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -506,7 +499,6 @@ type Actions =
| typeof setShippingAddress
| typeof shippingRatesBeingSelected
| typeof updateCustomerData
| typeof setFullShippingAddressPushed
| typeof updatingCustomerData;

export type CartAction = ReturnOrGeneratorYieldUnion< Actions | Thunks >;
1 change: 0 additions & 1 deletion assets/js/data/cart/default-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export const defaultCartState: CartState = {
applyingCoupon: '',
removingCoupon: '',
isCartDataStale: false,
fullShippingAddressPushed: false,
},
errors: EMPTY_CART_ERRORS,
};
6 changes: 0 additions & 6 deletions assets/js/data/cart/push-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -212,11 +211,6 @@ const updateCustomerData = debounce( (): void => {
) as BaseAddressKey[] ),
];
}
} )
.finally( () => {
if ( ! shippingAddressHasValidationErrors() ) {
dispatch( STORE_KEY ).setFullShippingAddressPushed( true );
}
} );
}
}, 1000 );
Expand Down
9 changes: 0 additions & 9 deletions assets/js/data/cart/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 0 additions & 5 deletions assets/js/data/cart/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,10 +27,6 @@ export const getCartData =
receiveError( CART_API_ERROR );
return;
}

if ( ! shippingAddressHasValidationErrors() ) {
dispatch.setFullShippingAddressPushed( true );
}
receiveCart( cartData );
};

Expand Down
7 changes: 0 additions & 7 deletions assets/js/data/cart/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 0 additions & 2 deletions assets/js/types/type-defs/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 >;
Expand Down

0 comments on commit ade3861

Please sign in to comment.