aboutsummaryrefslogtreecommitdiff
path: root/src/background/controllers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-26 16:24:14 +0900
committerGitHub <noreply@github.com>2019-05-26 16:24:14 +0900
commitcd584c8e243bafa8fc284279f716e8113607cd65 (patch)
treebc39bc30369f149e4ba4b6dc9c353b2906c4ef90 /src/background/controllers
parent07897df636ca3e732490d53fd2acf947738bf16e (diff)
parent34a96cdc9c5d7c8a11c6f1ae512fbc97724f61c4 (diff)
Merge pull request #592 from ueokande/repeat-last-operation
Add "repeat last operation" command
Diffstat (limited to 'src/background/controllers')
-rw-r--r--src/background/controllers/OperationController.ts36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts
index de6f8cb..51cff28 100644
--- a/src/background/controllers/OperationController.ts
+++ b/src/background/controllers/OperationController.ts
@@ -5,6 +5,8 @@ import ConsoleUseCase from '../usecases/ConsoleUseCase';
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 {
@@ -14,11 +16,20 @@ export default class OperationController {
private tabUseCase: TabUseCase,
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);
@@ -74,6 +85,29 @@ export default class OperationController {
return this.findUseCase.findStart();
case operations.CANCEL:
return this.consoleUseCase.hideConsole();
+ case operations.NAVIGATE_HISTORY_PREV:
+ return this.navigateUseCase.openHistoryPrev();
+ case operations.NAVIGATE_HISTORY_NEXT:
+ return this.navigateUseCase.openHistoryNext();
+ case operations.NAVIGATE_LINK_PREV:
+ return this.navigateUseCase.openLinkPrev();
+ case operations.NAVIGATE_LINK_NEXT:
+ return this.navigateUseCase.openLinkNext();
+ case operations.NAVIGATE_PARENT:
+ 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();
+ }
+ case operations.INTERNAL_OPEN_URL:
+ return this.tabUseCase.openURL(
+ operation.url, operation.newTab, operation.newWindow);
}
throw new Error('unknown operation: ' + operation.type);
}