add timestamps array

This commit is contained in:
Cale Newman 2015-07-30 23:20:33 -05:00
parent 1eeda8073a
commit e4f492d38b

View File

@ -76,7 +76,6 @@ function recomputeStates(reducer, committedState, stagedActions, skippedActions)
return computedStates; return computedStates;
} }
/** /**
* Lifts the app state reducer into a DevTools state reducer. * Lifts the app state reducer into a DevTools state reducer.
*/ */
@ -88,7 +87,8 @@ function liftReducer(reducer, initialState) {
currentStateIndex: 0, currentStateIndex: 0,
monitorState: { monitorState: {
isVisible: true isVisible: true
} },
timestamps: [Date.now()]
}; };
/** /**
@ -101,7 +101,8 @@ function liftReducer(reducer, initialState) {
skippedActions, skippedActions,
computedStates, computedStates,
currentStateIndex, currentStateIndex,
monitorState monitorState,
timestamps
} = liftedState; } = liftedState;
switch (liftedAction.type) { switch (liftedAction.type) {
@ -110,17 +111,20 @@ function liftReducer(reducer, initialState) {
stagedActions = [INIT_ACTION]; stagedActions = [INIT_ACTION];
skippedActions = {}; skippedActions = {};
currentStateIndex = 0; currentStateIndex = 0;
timestamps = [liftedAction.timestamp];
break; break;
case ActionTypes.COMMIT: case ActionTypes.COMMIT:
committedState = computedStates[currentStateIndex].state; committedState = computedStates[currentStateIndex].state;
stagedActions = [INIT_ACTION]; stagedActions = [INIT_ACTION];
skippedActions = {}; skippedActions = {};
currentStateIndex = 0; currentStateIndex = 0;
timestamps = [liftedAction.timestamp];
break; break;
case ActionTypes.ROLLBACK: case ActionTypes.ROLLBACK:
stagedActions = [INIT_ACTION]; stagedActions = [INIT_ACTION];
skippedActions = {}; skippedActions = {};
currentStateIndex = 0; currentStateIndex = 0;
timestamps = [liftedAction.timestamp];
break; break;
case ActionTypes.TOGGLE_ACTION: case ActionTypes.TOGGLE_ACTION:
skippedActions = toggle(skippedActions, liftedAction.index); skippedActions = toggle(skippedActions, liftedAction.index);
@ -130,6 +134,7 @@ function liftReducer(reducer, initialState) {
break; break;
case ActionTypes.SWEEP: case ActionTypes.SWEEP:
stagedActions = stagedActions.filter((_, i) => !skippedActions[i]); stagedActions = stagedActions.filter((_, i) => !skippedActions[i]);
timestamps = timestamps.filter((_, i) => !skippedActions[i]);
skippedActions = {}; skippedActions = {};
currentStateIndex = Math.min(currentStateIndex, stagedActions.length - 1); currentStateIndex = Math.min(currentStateIndex, stagedActions.length - 1);
break; break;
@ -138,6 +143,7 @@ function liftReducer(reducer, initialState) {
currentStateIndex++; currentStateIndex++;
} }
stagedActions = [...stagedActions, liftedAction.action]; stagedActions = [...stagedActions, liftedAction.action];
timestamps = [...timestamps, liftedAction.timestamp];
break; break;
case ActionTypes.SET_MONITOR_STATE: case ActionTypes.SET_MONITOR_STATE:
monitorState = liftedAction.monitorState; monitorState = liftedAction.monitorState;
@ -165,7 +171,8 @@ function liftReducer(reducer, initialState) {
skippedActions, skippedActions,
computedStates, computedStates,
currentStateIndex, currentStateIndex,
monitorState monitorState,
timestamps
}; };
}; };
} }
@ -174,7 +181,11 @@ function liftReducer(reducer, initialState) {
* Lifts an app action to a DevTools action. * Lifts an app action to a DevTools action.
*/ */
function liftAction(action) { function liftAction(action) {
const liftedAction = { type: ActionTypes.PERFORM_ACTION, action }; const liftedAction = {
type: ActionTypes.PERFORM_ACTION,
action,
timestamp: Date.now()
};
return liftedAction; return liftedAction;
} }
@ -215,13 +226,13 @@ function unliftStore(liftedStore, reducer) {
*/ */
export const ActionCreators = { export const ActionCreators = {
reset() { reset() {
return { type: ActionTypes.RESET }; return { type: ActionTypes.RESET, timestamp: Date.now() };
}, },
rollback() { rollback() {
return { type: ActionTypes.ROLLBACK }; return { type: ActionTypes.ROLLBACK, timestamp: Date.now() };
}, },
commit() { commit() {
return { type: ActionTypes.COMMIT }; return { type: ActionTypes.COMMIT, timestamp: Date.now() };
}, },
sweep() { sweep() {
return { type: ActionTypes.SWEEP }; return { type: ActionTypes.SWEEP };