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.
33 lines
1.1 KiB
33 lines
1.1 KiB
import { injectable } from 'tsyringe'; |
|
import IndicatorPresenter from '../presenters/IndicatorPresenter'; |
|
import TabPresenter from '../presenters/TabPresenter'; |
|
import ContentMessageClient from '../infrastructures/ContentMessageClient'; |
|
|
|
@injectable() |
|
export default class AddonEnabledUseCase { |
|
constructor( |
|
private indicatorPresentor: IndicatorPresenter, |
|
private tabPresenter: TabPresenter, |
|
private contentMessageClient: ContentMessageClient, |
|
) { |
|
this.indicatorPresentor.onClick((tab) => { |
|
if (tab.id) { |
|
this.onIndicatorClick(tab.id); |
|
} |
|
}); |
|
this.tabPresenter.onSelected(info => this.onTabSelected(info.tabId)); |
|
} |
|
|
|
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); |
|
} |
|
}
|
|
|