aboutsummaryrefslogtreecommitdiff
path: root/src/content/controllers/FollowMasterController.ts
blob: fa998204fd0afd86c77d205373766192813f62be (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
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);
    }
  }
}