This repository has been archived on 2020-04-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Vim-Vixen/src/background/usecases/addon-enabled.js
2018-07-22 15:39:23 +09:00

29 lines
900 B
JavaScript

import IndicatorPresenter from '../presenters/indicator';
import TabPresenter from '../presenters/tab';
import ContentMessageClient from '../infrastructures/content-message-client';
export default class AddonEnabledInteractor {
constructor() {
this.indicatorPresentor = new IndicatorPresenter();
this.indicatorPresentor.onClick(tab => this.onIndicatorClick(tab.id));
this.tabPresenter = new TabPresenter();
this.tabPresenter.onSelected(info => this.onTabSelected(info.tabId));
this.contentMessageClient = new ContentMessageClient();
}
indicate(enabled) {
this.indicatorPresentor.indicate(enabled);
}
onIndicatorClick(tabId) {
return this.contentMessageClient.toggleAddonEnabled(tabId);
}
async onTabSelected(tabId) {
let enabled = await this.contentMessageClient.getAddonEnabled(tabId);
return this.indicatorPresentor.indicate(enabled);
}
}