diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-22 20:44:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 20:44:07 +0900 |
commit | fa733c1ff110054f673f3d4e8d4760eb90d5d1eb (patch) | |
tree | 0a7d9f041a01d29f0bc5972a343e4988dc71b468 /src/content/operators/impls/ToggleAddonOperator.ts | |
parent | 3cbaf4a9f4245bd6be4eccdbff11e20ffaaf523a (diff) | |
parent | 690c9c080a2a511a30d555a90e5005e06b750351 (diff) |
Merge pull request #1043 from ueokande/iframe-late-inject
iframe Late injection
Diffstat (limited to 'src/content/operators/impls/ToggleAddonOperator.ts')
-rw-r--r-- | src/content/operators/impls/ToggleAddonOperator.ts | 15 |
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); } } |