Start with reducer/selector for loading entity

This commit is contained in:
emizzle 2018-08-20 23:32:15 +10:00 committed by Pascal Precht
parent 4d195657dd
commit e53152624f
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 3 additions and 6 deletions

View File

@ -119,11 +119,7 @@ function loadingEntities(state = {}, action) {
return state; return state;
} }
let newState = {}; let newState = {};
for (let name of Object.keys(entitiesDefaultState)) { newState[action.type].loading = action.loading;
if (action[name] && action[name].length > 0) {
newState[name] = action[name][0].loading || "Loading...";
}
}
return {...state, ...newState}; return {...state, ...newState};
} }

View File

@ -1,4 +1,5 @@
import _ from 'lodash'; import _ from 'lodash';
import {REQUEST, SUCCESS, FAILURE, FIDDLE, FIDDLE_DEPLOY} from '../actions';
export function getAccounts(state) { export function getAccounts(state) {
return state.entities.accounts; return state.entities.accounts;
@ -108,7 +109,7 @@ export function getFiddle(state) {
return { return {
data: _.last(state.entities.fiddles), data: _.last(state.entities.fiddles),
error: _.last(state.errorEntities.fiddles), error: _.last(state.errorEntities.fiddles),
loading: _.last(state.loadingEntities) loading: state.loadingEntities[FIDDLE[REQUEST]]
}; };
} }