aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/FollowOperatorFactoryChain.ts
blob: 588e1a4e33a791446bb82bf50cddd01d859a380f (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 { inject, injectable } from "tsyringe";
import StartFollowOperator from "./StartFollowOperator";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import FollowMasterClient from "../../client/FollowMasterClient";
import * as operations from "../../../shared/operations";

@injectable()
export default class FollowOperatorFactoryChain
  implements OperatorFactoryChain {
  constructor(
    @inject("FollowMasterClient")
    private followMasterClient: FollowMasterClient
  ) {}

  create(op: operations.Operation, _repeat: number): Operator | null {
    switch (op.type) {
      case operations.FOLLOW_START:
        return new StartFollowOperator(
          this.followMasterClient,
          op.newTab,
          op.background
        );
    }
    return null;
  }
}