diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-25 21:33:33 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-25 21:33:33 +0900 |
commit | ccbe08cf66e16084c919f0b2fa2da81258c01d41 (patch) | |
tree | 3257d852aeae93e4dc84fd3cabb63ebeefef326d /src/background/controllers | |
parent | 03370301a7509af4bbc96d60269598bf89c71fe4 (diff) |
Repeat last operation
Diffstat (limited to 'src/background/controllers')
-rw-r--r-- | src/background/controllers/OperationController.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts index 1e80f54..7233c0e 100644 --- a/src/background/controllers/OperationController.ts +++ b/src/background/controllers/OperationController.ts @@ -6,6 +6,7 @@ import TabUseCase from '../usecases/TabUseCase'; import TabSelectUseCase from '../usecases/TabSelectUseCase'; import ZoomUseCase from '../usecases/ZoomUseCase'; import NavigateUseCase from '../usecases/NavigateUseCase'; +import RepeatUseCase from '../usecases/RepeatUseCase'; @injectable() export default class OperationController { @@ -16,11 +17,19 @@ export default class OperationController { private tabSelectUseCase: TabSelectUseCase, private zoomUseCase: ZoomUseCase, private navigateUseCase: NavigateUseCase, + private repeatUseCase: RepeatUseCase, ) { } + async exec(op: operations.Operation): Promise<any> { + await this.doOperation(op); + if (this.repeatUseCase.isRepeatable(op)) { + this.repeatUseCase.storeLastOperation(op); + } + } + // eslint-disable-next-line complexity, max-lines-per-function - exec(operation: operations.Operation): Promise<any> { + doOperation(operation: operations.Operation): Promise<any> { switch (operation.type) { case operations.TAB_CLOSE: return this.tabUseCase.close(false); @@ -88,6 +97,14 @@ export default class OperationController { return this.navigateUseCase.openParent(); case operations.NAVIGATE_ROOT: return this.navigateUseCase.openRoot(); + case operations.REPEAT_LAST: + { + let last = this.repeatUseCase.getLastOperation(); + if (typeof last !== 'undefined') { + return this.doOperation(last); + } + return Promise.resolve(); + } } throw new Error('unknown operation: ' + operation.type); } |