A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
import IndicatorPresenter from '../presenters/IndicatorPresenter'; |
|
import TabPresenter from '../presenters/TabPresenter'; |
|
import ContentMessageClient from '../infrastructures/ContentMessageClient'; |
|
|
|
export default class AddonEnabledUseCase { |
|
private indicatorPresentor: IndicatorPresenter; |
|
|
|
private tabPresenter: TabPresenter; |
|
|
|
private contentMessageClient: ContentMessageClient; |
|
|
|
constructor() { |
|
this.indicatorPresentor = new IndicatorPresenter(); |
|
|
|
this.indicatorPresentor.onClick((tab) => { |
|
if (tab.id) { |
|
this.onIndicatorClick(tab.id); |
|
} |
|
}); |
|
|
|
this.tabPresenter = new TabPresenter(); |
|
this.tabPresenter.onSelected(info => this.onTabSelected(info.tabId)); |
|
|
|
this.contentMessageClient = new ContentMessageClient(); |
|
} |
|
|
|
indicate(enabled: boolean): Promise<void> { |
|
return this.indicatorPresentor.indicate(enabled); |
|
} |
|
|
|
onIndicatorClick(tabId: number): Promise<void> { |
|
return this.contentMessageClient.toggleAddonEnabled(tabId); |
|
} |
|
|
|
async onTabSelected(tabId: number): Promise<void> { |
|
let enabled = await this.contentMessageClient.getAddonEnabled(tabId); |
|
return this.indicatorPresentor.indicate(enabled); |
|
} |
|
}
|
|
|