From 04f4071fd3be298ef83c47633762591ed522ac02 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Thu, 12 May 2016 13:00:38 +0200 Subject: [PATCH] Handle loading message for empty topos correctly. It was showing infinite loading... --- client/app/scripts/actions/app-actions.js | 2 ++ client/app/scripts/constants/action-types.js | 1 + client/app/scripts/reducers/root.js | 16 ++++------------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 5704ccdd8..8ae665651 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -468,6 +468,8 @@ export function receiveNodeDetails(details) { export function receiveNodesDelta(delta) { return (dispatch, getState) => { + dispatch({ type: ActionTypes.SET_RECEIVED_NODES_DELTA }); + if (delta.add || delta.update || delta.remove) { const state = getState(); if (state.get('updatePausedAt') !== null) { diff --git a/client/app/scripts/constants/action-types.js b/client/app/scripts/constants/action-types.js index 9a4c0e44d..72d42793d 100644 --- a/client/app/scripts/constants/action-types.js +++ b/client/app/scripts/constants/action-types.js @@ -54,6 +54,7 @@ const ACTION_TYPES = [ 'PIN_NETWORK', 'UNPIN_NETWORK', 'SHOW_NETWORKS', + 'SET_RECEIVED_NODES_DELTA', ]; export default _.zipObject(ACTION_TYPES, ACTION_TYPES); diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index bc7c304ad..21f7d572a 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -10,7 +10,6 @@ import { getNetworkNodes, getAvailableNetworks } from '../utils/network-view-uti import { findTopologyById, getAdjacentNodes, setTopologyUrlsById, updateTopologyIds, filterHiddenTopologies } from '../utils/topology-utils'; -const log = debug('scope:app-store'); const error = debug('scope:error'); // Helpers @@ -481,18 +480,11 @@ export function rootReducer(state = initialState, action) { return state; } + case ActionTypes.SET_RECEIVED_NODES_DELTA: { + return state.set('nodesLoaded', true); + } + case ActionTypes.RECEIVE_NODES_DELTA: { - const emptyMessage = !action.delta.add && !action.delta.remove - && !action.delta.update; - state = state.set('nodesLoaded', true); - - if (!emptyMessage) { - log('RECEIVE_NODES_DELTA', - 'remove', _.size(action.delta.remove), - 'update', _.size(action.delta.update), - 'add', _.size(action.delta.add)); - } - state = state.set('errorUrl', null); // nodes that no longer exist