@@ -36,19 +36,27 @@ const initialState = {
36
36
const viewReducer = ( state = initialState , action ) => {
37
37
switch ( action . type ) {
38
38
/*
39
- * Note: Hard reset query state/object associated with a variant/productId. Remove this action type if restoring
40
- * queries based on product variant is needed, also review toolbar reducer for restoring/removing legend state.
39
+ * Note: Hard reset causes query state/object updates for ALL variants/productIds that have a filter selected,
40
+ * instead we focus the update to the specific variant to remove the extra API calls. Remove this entire
41
+ * action type if restoring queries based on product variant is needed, also review toolbar reducer for
42
+ * restoring/removing legend state.
41
43
*/
42
44
case reduxTypes . app . SET_PRODUCT_VARIANT_QUERY_RESET_ALL :
45
+ const updateVariantResetQueries = ( query = { } , id ) => {
46
+ const updatedQuery = query ;
47
+ delete updatedQuery [ id ] ;
48
+ return updatedQuery ;
49
+ } ;
50
+
43
51
return reduxHelpers . setStateProp (
44
52
null ,
45
53
{
46
54
...state ,
47
- query : { } ,
48
- graphTallyQuery : { } ,
49
- inventoryGuestsQuery : { } ,
50
- inventoryHostsQuery : { } ,
51
- inventorySubscriptionsQuery : { }
55
+ query : updateVariantResetQueries ( state . query , action . variant ) ,
56
+ graphTallyQuery : updateVariantResetQueries ( state . graphTallyQuery , action . variant ) ,
57
+ inventoryGuestsQuery : updateVariantResetQueries ( state . inventoryGuestsQuery , action . variant ) ,
58
+ inventoryHostsQuery : updateVariantResetQueries ( state . inventoryHostsQuery , action . variant ) ,
59
+ inventorySubscriptionsQuery : updateVariantResetQueries ( state . inventorySubscriptionsQuery , action . variant )
52
60
} ,
53
61
{
54
62
state,
0 commit comments