aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers/FollowMasterController.ts
blob: e7895fa05944fe07f3135b607d9d7c872c1b0084 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { injectable } from "tsyringe";
import FollowMasterUseCase from "../usecases/FollowMasterUseCase";
import * as messages from "../../shared/messages";

@injectable()
export default class FollowMasterController {
  constructor(private followMasterUseCase: FollowMasterUseCase) {}

  followStart(m: messages.FollowStartMessage): void {
    this.followMasterUseCase.startFollow(m.newTab, m.background);
  }

  responseCountTargets(
    m: messages.FollowResponseCountTargetsMessage,
    sender: Window
  ): void {
    this.followMasterUseCase.createSlaveHints(m.count, sender);
  }

  keyPress(message: messages.FollowKeyPressMessage): void {
    if (message.key === "[" && message.ctrlKey) {
      this.followMasterUseCase.cancelFollow();
    } else {
      this.followMasterUseCase.enqueue(message.key);
    }
  }
}