mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 03:46:45 +00:00
keep nodes cache intact while websocket is closed
This commit is contained in:
@@ -39,6 +39,11 @@ describe('AppStore', function() {
|
||||
type: ActionTypes.HIT_ESC_KEY
|
||||
};
|
||||
|
||||
const ReceiveEmptyNodesDeltaAction = {
|
||||
type: ActionTypes.RECEIVE_NODES_DELTA,
|
||||
delta: {}
|
||||
};
|
||||
|
||||
const ReceiveNodesDeltaAction = {
|
||||
type: ActionTypes.RECEIVE_NODES_DELTA,
|
||||
delta: {
|
||||
@@ -146,6 +151,9 @@ describe('AppStore', function() {
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
|
||||
registeredCallback(CloseWebsocketAction);
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
|
||||
registeredCallback(ReceiveEmptyNodesDeltaAction);
|
||||
expect(AppStore.getNodes()).toEqual({});
|
||||
});
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ let nodes = {};
|
||||
let nodeDetails = null;
|
||||
let selectedNodeId = null;
|
||||
let topologies = [];
|
||||
let websocketClosed = true;
|
||||
|
||||
// Store API
|
||||
|
||||
@@ -162,7 +163,7 @@ AppStore.registeredCallback = function(payload) {
|
||||
break;
|
||||
|
||||
case ActionTypes.CLOSE_WEBSOCKET:
|
||||
nodes = {};
|
||||
websocketClosed = true;
|
||||
AppStore.emit(AppStore.CHANGE_EVENT);
|
||||
break;
|
||||
|
||||
@@ -211,6 +212,12 @@ AppStore.registeredCallback = function(payload) {
|
||||
|
||||
errorUrl = null;
|
||||
|
||||
// flush nodes cache after re-connect
|
||||
if (websocketClosed) {
|
||||
nodes = {};
|
||||
}
|
||||
websocketClosed = false;
|
||||
|
||||
// nodes that no longer exist
|
||||
_.each(payload.delta.remove, function(nodeId) {
|
||||
// in case node disappears before mouseleave event
|
||||
|
||||
Reference in New Issue
Block a user