blob: 54880c4fcee6ad53108e4dfaf04f36dbafe8c063 (
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
|
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";
@injectable()
export default class AddonOperatorFactoryChain implements OperatorFactoryChain {
constructor(
@inject("AddonIndicatorClient")
private readonly addonIndicatorClient: AddonIndicatorClient,
@inject("AddonEnabledRepository")
private readonly addonEnabledRepository: AddonEnabledRepository
) {}
create(op: operations.Operation, _repeat: number): Operator | null {
switch (op.type) {
case operations.ADDON_ENABLE:
return new EnableAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository
);
case operations.ADDON_DISABLE:
return new DisableAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository
);
case operations.ADDON_TOGGLE_ENABLED:
return new ToggleAddonOperator(
this.addonIndicatorClient,
this.addonEnabledRepository
);
}
return null;
}
}
|