File size: 707 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import { withStorageKey } from '@automattic/state-utils';
import { reject } from 'lodash';
import {
CONNECTED_APPLICATION_DELETE_SUCCESS,
CONNECTED_APPLICATIONS_RECEIVE,
} from 'calypso/state/action-types';
import { withSchemaValidation } from 'calypso/state/utils';
import schema from './schema';
const reducer = ( state = null, action ) => {
switch ( action.type ) {
case CONNECTED_APPLICATION_DELETE_SUCCESS:
return reject( state, { ID: action.appId } );
case CONNECTED_APPLICATIONS_RECEIVE:
return action.apps;
default:
return state;
}
};
const validatedReducer = withSchemaValidation( schema, reducer );
export default withStorageKey( 'connectedApplications', validatedReducer );
|