aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers/FollowMasterController.ts
blob: 89294ff651b528ded93874df65c23584ce3f656b (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
28
29
30
31
import FollowMasterUseCase from '../usecases/FollowMasterUseCase';
import * as messages from '../../shared/messages';

export default class FollowMasterController {
  private followMasterUseCase: FollowMasterUseCase;

  constructor({
    followMasterUseCase = new FollowMasterUseCase(),
  } = {}) {
    this.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);
    }
  }
}