Server IP : 104.21.14.103 / Your IP : 18.118.142.17 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/collections/ |
Upload File : |
/** * Internal dependencies */ import { ACTION_TYPES as types } from './action-types'; import { hasInState, updateState } from '../utils'; /** * Reducer for receiving items to a collection. * * @param {Object} state The current state in the store. * @param {Object} action Action object. * * @return {Object} New or existing state depending on if there are * any changes. */ const receiveCollection = ( state = {}, action ) => { // Update last modified and previous last modified values. if ( action.type === types.RECEIVE_LAST_MODIFIED ) { if ( action.timestamp === state.lastModified ) { return state; } return { ...state, lastModified: action.timestamp, }; } // When invalidating data, remove stored values from state. if ( action.type === types.INVALIDATE_RESOLUTION_FOR_STORE ) { return {}; } const { type, namespace, resourceName, queryString, response } = action; // ids are stringified so they can be used as an index. const ids = action.ids ? JSON.stringify( action.ids ) : '[]'; switch ( type ) { case types.RECEIVE_COLLECTION: if ( hasInState( state, [ namespace, resourceName, ids, queryString, ] ) ) { return state; } state = updateState( state, [ namespace, resourceName, ids, queryString ], response ); break; case types.RESET_COLLECTION: state = updateState( state, [ namespace, resourceName, ids, queryString ], response ); break; case types.ERROR: state = updateState( state, [ namespace, resourceName, ids, queryString ], response ); break; } return state; }; export default receiveCollection;