blob: 454aea13afedddec735f6a4d103bb24f7edd56b7 (
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
47
|
import { inject, injectable } from "tsyringe";
import YankURLOperator from "./YankURLOperator";
import PasteOperator from "./PasteOperator";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import ClipboardRepository from "../../repositories/ClipboardRepository";
import ConsoleClient from "../../client/ConsoleClient";
import OperationClient from "../../client/OperationClient";
import SettingRepository from "../../repositories/SettingRepository";
import * as operations from "../../../shared/operations";
import URLRepository from "./URLRepository";
@injectable()
export default class ClipboardOperatorFactoryChain
implements OperatorFactoryChain {
constructor(
@inject("ClipboardRepository")
private readonly clipboardRepository: ClipboardRepository,
@inject("ConsoleClient")
private readonly consoleClient: ConsoleClient,
@inject("OperationClient")
private readonly operationClinet: OperationClient,
@inject("SettingRepository")
private readonly settingRepository: SettingRepository,
@inject("URLRepository")
private readonly urlRepository: URLRepository
) {}
create(op: operations.Operation, _repeat: number): Operator | null {
switch (op.type) {
case operations.URLS_YANK:
return new YankURLOperator(
this.clipboardRepository,
this.consoleClient,
this.urlRepository
);
case operations.URLS_PASTE:
return new PasteOperator(
this.clipboardRepository,
this.settingRepository,
this.operationClinet,
op.newTab
);
}
return null;
}
}
|