diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 854a1c1d45..2fdb00739e 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -551,7 +551,7 @@ export function receiveNodesDelta(delta) { dispatch({ type: ActionTypes.FINISH_TIME_TRAVEL_TRANSITION }); } - const hasChanges = delta.add || delta.update || delta.remove; + const hasChanges = delta.add || delta.update || delta.remove || delta.reset; if (hasChanges) { dispatch({ type: ActionTypes.RECEIVE_NODES_DELTA, diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index 734383f0f7..751352837b 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -582,7 +582,12 @@ export function rootReducer(state = initialState, action) { log('RECEIVE_NODES_DELTA', 'remove', size(action.delta.remove), 'update', size(action.delta.update), - 'add', size(action.delta.add)); + 'add', size(action.delta.add), + 'reset', action.delta.reset); + + if (action.delta.reset) { + state = state.set('nodes', makeMap()); + } // remove nodes that no longer exist each(action.delta.remove, (nodeId) => { diff --git a/render/detailed/topology_diff.go b/render/detailed/topology_diff.go index 66836d5b89..aabeb6f395 100644 --- a/render/detailed/topology_diff.go +++ b/render/detailed/topology_diff.go @@ -10,11 +10,12 @@ type Diff struct { Add []NodeSummary `json:"add"` Update []NodeSummary `json:"update"` Remove []string `json:"remove"` + Reset bool `json:"reset,omitempty"` } // TopoDiff gives you the diff to get from A to B. func TopoDiff(a, b NodeSummaries) Diff { - diff := Diff{} + diff := Diff{Reset: a == nil} notSeen := map[string]struct{}{} for k := range a { diff --git a/render/detailed/topology_diff_test.go b/render/detailed/topology_diff_test.go index 35bfdf9e6c..3a630031af 100644 --- a/render/detailed/topology_diff_test.go +++ b/render/detailed/topology_diff_test.go @@ -79,6 +79,22 @@ func TestTopoDiff(t *testing.T) { Update: []detailed.NodeSummary{nodeap}, }, }, + { + label: "no previous nodes", + have: detailed.TopoDiff(nil, nodes(nodea)), + want: detailed.Diff{ + Add: []detailed.NodeSummary{nodea}, + Reset: true, + }, + }, + { + label: "empty previous nodes", + have: detailed.TopoDiff(nodes(), nodes(nodea)), + want: detailed.Diff{ + Add: []detailed.NodeSummary{nodea}, + Reset: false, + }, + }, } { sort.Strings(c.have.Remove) sort.Sort(ByID(c.have.Add))