Flatten the store of the profile feature

This commit is contained in:
zbettenbuk 2018-02-06 13:18:05 +01:00 committed by Lyubo Marinov
parent 0e07020d09
commit d02ab2c641
2 changed files with 4 additions and 12 deletions

View File

@ -11,5 +11,5 @@
export function getProfile(state: Object) {
const profileStateSlice = state['features/base/profile'];
return profileStateSlice ? profileStateSlice.profile || {} : {};
return profileStateSlice || {};
}

View File

@ -5,26 +5,18 @@ import { PersistenceRegistry } from '../storage';
import { PROFILE_UPDATED } from './actionTypes';
const DEFAULT_STATE = {
profile: {}
};
const STORE_NAME = 'features/base/profile';
/**
* Sets up the persistence of the feature base/profile.
*/
PersistenceRegistry.register(STORE_NAME, {
profile: true
});
PersistenceRegistry.register(STORE_NAME);
ReducerRegistry.register(
STORE_NAME, (state = DEFAULT_STATE, action) => {
STORE_NAME, (state = {}, action) => {
switch (action.type) {
case PROFILE_UPDATED:
return {
profile: action.profile
};
return action.profile;
}
return state;