From 3ffb4b066cdcc60a49ce4ecd0bbc498da6256534 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Wed, 17 Mar 2021 23:20:41 +0900 Subject: Attach/detach console iframe on addon enabled/disabled --- src/content/operators/impls/ToggleAddonOperator.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/content/operators/impls/ToggleAddonOperator.ts') 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 { - 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); } } -- cgit v1.2.3