Server IP : 104.21.14.103 / Your IP : 18.216.34.208 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/home/giankuin/sieuthiweb.com.vn/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/query-state/ |
Upload File : |
/** * Internal dependencies */ import { ACTION_TYPES as types } from './action-types'; import { getStateForContext } from './utils'; /** * Reducer for processing actions related to the query state store. * * @param {Object} state Current state in store. * @param {Object} action Action being processed. */ const queryStateReducer = ( state = {}, action ) => { const { type, context, queryKey, value } = action; const prevState = getStateForContext( state, context ); let newState; switch ( type ) { case types.SET_QUERY_KEY_VALUE: const prevStateObject = prevState !== null ? JSON.parse( prevState ) : {}; // mutate it and JSON.stringify to compare prevStateObject[ queryKey ] = value; newState = JSON.stringify( prevStateObject ); if ( prevState !== newState ) { state = { ...state, [ context ]: newState, }; } break; case types.SET_QUERY_CONTEXT_VALUE: newState = JSON.stringify( value ); if ( prevState !== newState ) { state = { ...state, [ context ]: newState, }; } break; } return state; }; export default queryStateReducer;