From e53152624fe24d9082361ca8a4d04bb3b1e6637c Mon Sep 17 00:00:00 2001 From: emizzle Date: Mon, 20 Aug 2018 23:32:15 +1000 Subject: [PATCH] Start with reducer/selector for loading entity --- embark-ui/src/reducers/index.js | 6 +----- embark-ui/src/reducers/selectors.js | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js index 642d7eaf3..e13444948 100644 --- a/embark-ui/src/reducers/index.js +++ b/embark-ui/src/reducers/index.js @@ -119,11 +119,7 @@ function loadingEntities(state = {}, action) { return state; } let newState = {}; - for (let name of Object.keys(entitiesDefaultState)) { - if (action[name] && action[name].length > 0) { - newState[name] = action[name][0].loading || "Loading..."; - } - } + newState[action.type].loading = action.loading; return {...state, ...newState}; } diff --git a/embark-ui/src/reducers/selectors.js b/embark-ui/src/reducers/selectors.js index e93786d27..66a5d7bb1 100644 --- a/embark-ui/src/reducers/selectors.js +++ b/embark-ui/src/reducers/selectors.js @@ -1,4 +1,5 @@ import _ from 'lodash'; +import {REQUEST, SUCCESS, FAILURE, FIDDLE, FIDDLE_DEPLOY} from '../actions'; export function getAccounts(state) { return state.entities.accounts; @@ -108,7 +109,7 @@ export function getFiddle(state) { return { data: _.last(state.entities.fiddles), error: _.last(state.errorEntities.fiddles), - loading: _.last(state.loadingEntities) + loading: state.loadingEntities[FIDDLE[REQUEST]] }; }