aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/ToggleAddonOperator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/operators/impls/ToggleAddonOperator.ts')
-rw-r--r--src/content/operators/impls/ToggleAddonOperator.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/content/operators/impls/ToggleAddonOperator.ts b/src/content/operators/impls/ToggleAddonOperator.ts
new file mode 100644
index 0000000..2a249d6
--- /dev/null
+++ b/src/content/operators/impls/ToggleAddonOperator.ts
@@ -0,0 +1,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);
+ }
+}