diff options
Diffstat (limited to 'src/content/operators')
4 files changed, 29 insertions, 10 deletions
diff --git a/src/content/operators/impls/AddonOperatorFactoryChain.ts b/src/content/operators/impls/AddonOperatorFactoryChain.ts index 54880c4..5e464e8 100644 --- a/src/content/operators/impls/AddonOperatorFactoryChain.ts +++ b/src/content/operators/impls/AddonOperatorFactoryChain.ts @@ -7,6 +7,7 @@ import Operator from "../Operator"; import EnableAddonOperator from "./EnableAddonOperator"; import DisableAddonOperator from "./DisableAddonOperator"; import ToggleAddonOperator from "./ToggleAddonOperator"; +import ConsoleFramePresenter from "../../presenters/ConsoleFramePresenter"; @injectable() export default class AddonOperatorFactoryChain implements OperatorFactoryChain { @@ -14,7 +15,9 @@ export default class AddonOperatorFactoryChain implements OperatorFactoryChain { @inject("AddonIndicatorClient") private readonly addonIndicatorClient: AddonIndicatorClient, @inject("AddonEnabledRepository") - private readonly addonEnabledRepository: AddonEnabledRepository + private readonly addonEnabledRepository: AddonEnabledRepository, + @inject("ConsoleFramePresenter") + private readonly consoleFramePresenter: ConsoleFramePresenter ) {} create(op: operations.Operation, _repeat: number): Operator | null { @@ -22,17 +25,20 @@ export default class AddonOperatorFactoryChain implements OperatorFactoryChain { case operations.ADDON_ENABLE: return new EnableAddonOperator( this.addonIndicatorClient, - this.addonEnabledRepository + this.addonEnabledRepository, + this.consoleFramePresenter ); case operations.ADDON_DISABLE: return new DisableAddonOperator( this.addonIndicatorClient, - this.addonEnabledRepository + this.addonEnabledRepository, + this.consoleFramePresenter ); case operations.ADDON_TOGGLE_ENABLED: return new ToggleAddonOperator( this.addonIndicatorClient, - this.addonEnabledRepository + this.addonEnabledRepository, + this.consoleFramePresenter ); } return null; diff --git a/src/content/operators/impls/DisableAddonOperator.ts b/src/content/operators/impls/DisableAddonOperator.ts index 28811fe..a92e04b 100644 --- a/src/content/operators/impls/DisableAddonOperator.ts +++ b/src/content/operators/impls/DisableAddonOperator.ts @@ -1,15 +1,18 @@ import Operator from "../Operator"; import AddonIndicatorClient from "../../client/AddonIndicatorClient"; import AddonEnabledRepository from "../../repositories/AddonEnabledRepository"; +import ConsoleFramePresenter from "../../presenters/ConsoleFramePresenter"; export default class DisableAddonOperator implements Operator { constructor( private readonly indicator: AddonIndicatorClient, - private readonly repository: AddonEnabledRepository + private readonly repository: AddonEnabledRepository, + private readonly consoleFramePresenter: ConsoleFramePresenter ) {} async run(): Promise<void> { this.repository.set(false); + this.consoleFramePresenter.detach(); await this.indicator.setEnabled(false); } } diff --git a/src/content/operators/impls/EnableAddonOperator.ts b/src/content/operators/impls/EnableAddonOperator.ts index b5b1d79..fe2b771 100644 --- a/src/content/operators/impls/EnableAddonOperator.ts +++ b/src/content/operators/impls/EnableAddonOperator.ts @@ -1,15 +1,18 @@ import Operator from "../Operator"; import AddonIndicatorClient from "../../client/AddonIndicatorClient"; import AddonEnabledRepository from "../../repositories/AddonEnabledRepository"; +import ConsoleFramePresenter from "../../presenters/ConsoleFramePresenter"; export default class EnableAddonOperator implements Operator { constructor( private readonly indicator: AddonIndicatorClient, - private readonly repository: AddonEnabledRepository + private readonly repository: AddonEnabledRepository, + private readonly consoleFramePresenter: ConsoleFramePresenter ) {} async run(): Promise<void> { this.repository.set(true); + this.consoleFramePresenter.attach(); await this.indicator.setEnabled(true); } } 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); } } |