From df2411f40aefd7181b441f1a97e322f1c77d274f Mon Sep 17 00:00:00 2001 From: Tim Deschryver Date: Wed, 21 Mar 2018 20:25:19 +0100 Subject: [PATCH] fix(StoreDevtools): pass timestamp to actions --- modules/store-devtools/spec/extension.spec.ts | 2 +- modules/store-devtools/src/actions.ts | 8 ++++---- modules/store-devtools/src/devtools.ts | 8 ++++---- modules/store-devtools/src/reducer.ts | 2 +- modules/store-devtools/src/utils.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/store-devtools/spec/extension.spec.ts b/modules/store-devtools/spec/extension.spec.ts index c59bf3a880..979720e6f2 100644 --- a/modules/store-devtools/spec/extension.spec.ts +++ b/modules/store-devtools/spec/extension.spec.ts @@ -170,7 +170,7 @@ describe('DevtoolsExtension', () => { const SANITIZED_COUNTER = 42; function createPerformAction() { - return new PerformAction({ type: UNSANITIZED_TOKEN }); + return new PerformAction({ type: UNSANITIZED_TOKEN }, +Date.now()); } function testActionSanitizer(action: Action, id: number) { diff --git a/modules/store-devtools/src/actions.ts b/modules/store-devtools/src/actions.ts index ce0cd1aaa9..a52683e6e0 100644 --- a/modules/store-devtools/src/actions.ts +++ b/modules/store-devtools/src/actions.ts @@ -14,7 +14,7 @@ export const IMPORT_STATE = 'IMPORT_STATE'; export class PerformAction implements Action { readonly type = PERFORM_ACTION; - constructor(public action: Action, public timestamp?: number) { + constructor(public action: Action, public timestamp: number) { if (typeof action.type === 'undefined') { throw new Error( 'Actions may not have an undefined "type" property. ' + @@ -27,19 +27,19 @@ export class PerformAction implements Action { export class Reset implements Action { readonly type = RESET; - constructor(public timestamp?: number) {} + constructor(public timestamp: number) {} } export class Rollback implements Action { readonly type = ROLLBACK; - constructor(public timestamp?: number) {} + constructor(public timestamp: number) {} } export class Commit implements Action { readonly type = COMMIT; - constructor(public timestamp?: number) {} + constructor(public timestamp: number) {} } export class Sweep implements Action { diff --git a/modules/store-devtools/src/devtools.ts b/modules/store-devtools/src/devtools.ts index 31ff1fc4f9..f117ea45ae 100644 --- a/modules/store-devtools/src/devtools.ts +++ b/modules/store-devtools/src/devtools.ts @@ -119,19 +119,19 @@ export class StoreDevtools implements Observer { complete() {} performAction(action: any) { - this.dispatch(new Actions.PerformAction(action)); + this.dispatch(new Actions.PerformAction(action, +Date.now())); } reset() { - this.dispatch(new Actions.Reset()); + this.dispatch(new Actions.Reset(+Date.now())); } rollback() { - this.dispatch(new Actions.Rollback()); + this.dispatch(new Actions.Rollback(+Date.now())); } commit() { - this.dispatch(new Actions.Commit()); + this.dispatch(new Actions.Commit(+Date.now())); } sweep() { diff --git a/modules/store-devtools/src/reducer.ts b/modules/store-devtools/src/reducer.ts index efcdaa1422..9719b6ef22 100644 --- a/modules/store-devtools/src/reducer.ts +++ b/modules/store-devtools/src/reducer.ts @@ -392,7 +392,7 @@ export function liftReducerWith( // Add a new action to only recompute state const actionId = nextActionId++; - actionsById[actionId] = new PerformAction(liftedAction); + actionsById[actionId] = new PerformAction(liftedAction, +Date.now()); stagedActionIds = [...stagedActionIds, actionId]; minInvalidatedStateIndex = stagedActionIds.length - 1; diff --git a/modules/store-devtools/src/utils.ts b/modules/store-devtools/src/utils.ts index 996486ca84..3adf008dfa 100644 --- a/modules/store-devtools/src/utils.ts +++ b/modules/store-devtools/src/utils.ts @@ -32,7 +32,7 @@ export function unliftAction(liftedState: LiftedState): LiftedAction { * Lifts an app's action into an action on the lifted store. */ export function liftAction(action: Action) { - return new Actions.PerformAction(action); + return new Actions.PerformAction(action, +Date.now()); } /**