aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/ToggleAddonOperator.ts
blob: 2a249d6a6793b42ac379fec24c9d642f38851cf0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import Operator from "../Operator";
import AddonIndicatorClient from "../../client/AddonIndicatorClient";
import AddonEnabledRepository from "../../repositories/AddonEnabledRepository";

export default class ToggleAddonOperator implements Operator {
  constructor(
    private readonly indicator: AddonIndicatorClient,
    private readonly repository: AddonEnabledRepository
  ) {}

  async run(): Promise<void> {
    const current = this.repository.get();
    this.repository.set(!current);
    await this.indicator.setEnabled(!current);
  }
}