From e8ec3ed5fc8e6ba3765efb7468bb7f38491537c5 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 2 Sep 2015 16:38:24 +0200 Subject: [PATCH] fix nodes immutable after socket opens fix for PR #410 --- client/app/scripts/stores/__tests__/app-store-test.js | 9 ++------- client/app/scripts/stores/app-store.js | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/client/app/scripts/stores/__tests__/app-store-test.js b/client/app/scripts/stores/__tests__/app-store-test.js index 31abf96e4..e82fcba11 100644 --- a/client/app/scripts/stores/__tests__/app-store-test.js +++ b/client/app/scripts/stores/__tests__/app-store-test.js @@ -60,11 +60,6 @@ describe('AppStore', function() { type: ActionTypes.OPEN_WEBSOCKET }; - const ReceiveEmptyNodesDeltaAction = { - type: ActionTypes.RECEIVE_NODES_DELTA, - delta: {} - }; - const ReceiveNodesDeltaAction = { type: ActionTypes.RECEIVE_NODES_DELTA, delta: { @@ -189,12 +184,12 @@ describe('AppStore', function() { registeredCallback(CloseWebsocketAction); expect(AppStore.isWebsocketClosed()).toBeTruthy(); + // keep showing old nodes expect(AppStore.getNodes().toJS()).toEqual(NODE_SET); registeredCallback(OpenWebsocketAction); expect(AppStore.isWebsocketClosed()).toBeFalsy(); - - registeredCallback(ReceiveEmptyNodesDeltaAction); + // opened socket clears nodes expect(AppStore.getNodes().toJS()).toEqual({}); }); diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js index 385530f21..f52ad3b03 100644 --- a/client/app/scripts/stores/app-store.js +++ b/client/app/scripts/stores/app-store.js @@ -176,7 +176,6 @@ AppStore.registeredCallback = function(payload) { break; case ActionTypes.CLOSE_WEBSOCKET: - nodes = nodes.clear(); websocketClosed = true; AppStore.emit(AppStore.CHANGE_EVENT); break; @@ -209,7 +208,7 @@ AppStore.registeredCallback = function(payload) { case ActionTypes.OPEN_WEBSOCKET: // flush nodes cache after re-connect - nodes = {}; + nodes = nodes.clear(); websocketClosed = false; AppStore.emit(AppStore.CHANGE_EVENT);