loading entity work

This commit is contained in:
emizzle 2018-08-22 10:19:27 +10:00 committed by Pascal Precht
parent e53152624f
commit 83326bfd98
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 5 additions and 3 deletions

View File

@ -119,7 +119,8 @@ function loadingEntities(state = {}, action) {
return state;
}
let newState = {};
newState[action.type].loading = action.loading;
if(!newState[action.type]) newState[action.type] = {};
newState[action.type].loading = action.loading || 'Loading...';
return {...state, ...newState};
}

View File

@ -1,5 +1,5 @@
import _ from 'lodash';
import {REQUEST, SUCCESS, FAILURE, FIDDLE, FIDDLE_DEPLOY} from '../actions';
import {REQUEST, FIDDLE} from '../actions/index.js';
export function getAccounts(state) {
return state.entities.accounts;
@ -106,10 +106,11 @@ export function getMessages(state) {
}
export function getFiddle(state) {
const loadingEntity = state.loadingEntities[FIDDLE[REQUEST]];
return {
data: _.last(state.entities.fiddles),
error: _.last(state.errorEntities.fiddles),
loading: state.loadingEntities[FIDDLE[REQUEST]]
loading: loadingEntity ? loadingEntity.loading : undefined
};
}