From f19e4c55cd1b9bb34358d38b5fafa44ea59e9ebb Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Mon, 31 Jul 2017 16:16:27 +0200 Subject: [PATCH 1/2] Resume time works only if previously paused. --- client/app/scripts/actions/app-actions.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 009f8a330..ce7655698 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -574,14 +574,16 @@ export function receiveNodesDelta(delta) { export function resumeTime() { return (dispatch, getState) => { - dispatch({ - type: ActionTypes.RESUME_TIME - }); - // After unpausing, all of the following calls will re-activate polling. - getTopologies(getState, dispatch); - getNodes(getState, dispatch, true); - if (isResourceViewModeSelector(getState())) { - getResourceViewNodesSnapshot(getState(), dispatch); + if (isPausedSelector(getState())) { + dispatch({ + type: ActionTypes.RESUME_TIME + }); + // After unpausing, all of the following calls will re-activate polling. + getTopologies(getState, dispatch); + getNodes(getState, dispatch, true); + if (isResourceViewModeSelector(getState())) { + getResourceViewNodesSnapshot(getState(), dispatch); + } } }; } From 0c7896222cd0b4e044a90bee4759d33dfd56788b Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Thu, 10 Aug 2017 16:36:33 +0200 Subject: [PATCH 2/2] Exit time travel mode as a part of the app shutdown(). --- client/app/scripts/actions/app-actions.js | 14 ++++++++++---- client/app/scripts/components/time-travel.js | 5 ----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index ce7655698..88be513df 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -798,10 +798,16 @@ export function changeInstance() { } export function shutdown() { - stopPolling(); - teardownWebsockets(); - return { - type: ActionTypes.SHUTDOWN + return (dispatch) => { + stopPolling(); + teardownWebsockets(); + // Exit the time travel mode before unmounting the app. + dispatch({ + type: ActionTypes.RESUME_TIME + }); + dispatch({ + type: ActionTypes.SHUTDOWN + }); }; } diff --git a/client/app/scripts/components/time-travel.js b/client/app/scripts/components/time-travel.js index c1f424f15..1a94acb40 100644 --- a/client/app/scripts/components/time-travel.js +++ b/client/app/scripts/components/time-travel.js @@ -47,11 +47,6 @@ class TimeTravel extends React.Component { this.setState(getTimestampStates(props.pausedAt)); } - componentWillUnmount() { - // TODO: Get rid of this somehow. See: https://github.com/weaveworks/service-ui/issues/814 - this.props.resumeTime(); - } - handleInputChange(ev) { const timestamp = moment(ev.target.value); this.setState({ inputValue: ev.target.value });