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.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/content/operators/impls/ToggleAddonOperator.ts b/src/content/operators/impls/ToggleAddonOperator.ts
index 2a249d6..1019b8b 100644
--- a/src/content/operators/impls/ToggleAddonOperator.ts
+++ b/src/content/operators/impls/ToggleAddonOperator.ts
@@ -1,16 +1,23 @@
import Operator from "../Operator";
import AddonIndicatorClient from "../../client/AddonIndicatorClient";
import AddonEnabledRepository from "../../repositories/AddonEnabledRepository";
+import ConsoleFramePresenter from "../../presenters/ConsoleFramePresenter";
export default class ToggleAddonOperator implements Operator {
constructor(
private readonly indicator: AddonIndicatorClient,
- private readonly repository: AddonEnabledRepository
+ private readonly repository: AddonEnabledRepository,
+ private readonly consoleFramePresenter: ConsoleFramePresenter
) {}
async run(): Promise<void> {
- const current = this.repository.get();
- this.repository.set(!current);
- await this.indicator.setEnabled(!current);
+ const enabled = !this.repository.get();
+ this.repository.set(enabled);
+ if (enabled) {
+ this.consoleFramePresenter.attach();
+ } else {
+ this.consoleFramePresenter.detach();
+ }
+ await this.indicator.setEnabled(enabled);
}
}