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) { export function getProfile(state: Object) {
const profileStateSlice = state['features/base/profile']; 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'; import { PROFILE_UPDATED } from './actionTypes';
const DEFAULT_STATE = {
profile: {}
};
const STORE_NAME = 'features/base/profile'; const STORE_NAME = 'features/base/profile';
/** /**
* Sets up the persistence of the feature base/profile. * Sets up the persistence of the feature base/profile.
*/ */
PersistenceRegistry.register(STORE_NAME, { PersistenceRegistry.register(STORE_NAME);
profile: true
});
ReducerRegistry.register( ReducerRegistry.register(
STORE_NAME, (state = DEFAULT_STATE, action) => { STORE_NAME, (state = {}, action) => {
switch (action.type) { switch (action.type) {
case PROFILE_UPDATED: case PROFILE_UPDATED:
return { return action.profile;
profile: action.profile
};
} }
return state; return state;