blob: 5e464e805d7728f539fe64ef80c7d33015d78b3f (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { inject, injectable } from "tsyringe";
import OperatorFactoryChain from "../OperatorFactoryChain";
import AddonIndicatorClient from "../../client/AddonIndicatorClient";
import AddonEnabledRepository from "../../repositories/AddonEnabledRepository";
import * as operations from "../../../shared/operations";
import Operator from "../Operator";
import EnableAddonOperator from "./EnableAddonOperator";
import DisableAddonOperator from "./DisableAddonOperator";
import ToggleAddonOperator from "./ToggleAddonOperator";
import ConsoleFramePresenter from "../../presenters/ConsoleFramePresenter";
@injectable()
export default class AddonOperatorFactoryChain implements OperatorFactoryChain {
constructor(
@inject("AddonIndicatorClient")
private readonly addonIndicatorClient: AddonIndicatorClient,
@inject("AddonEnabledRepository")
private readonly addonEnabledRepository: AddonEnabledRepository,
@inject("ConsoleFramePresenter")
private readonly consoleFramePresenter: ConsoleFramePresenter
) {}
create(op: operations.Operation, _repeat: number): Operator | null {
switch (op.type) {
case operations.ADDON_ENABLE:
return new EnableAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository,
this.consoleFramePresenter
);
case operations.ADDON_DISABLE:
return new DisableAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository,
this.consoleFramePresenter
);
case operations.ADDON_TOGGLE_ENABLED:
return new ToggleAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository,
this.consoleFramePresenter
);
}
return null;
}
}
|