aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/link.js
blob: af152fe753f0fde3a7189bd42b62a4e289a8d240 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import SettingRepository from '../repositories/setting';
import TabPresenter from '../presenters/tab';

export default class LinkInteractor {
  constructor() {
    this.settingRepository = new SettingRepository();
    this.tabPresenter = new TabPresenter();
  }

  openToTab(url, tabId) {
    return this.tabPresenter.open(url, tabId);
  }

  async openNewTab(url, openerId, background) {
    let settings = await this.settingRepository.get();
    let { adjacenttab } = settings.properties;
    if (adjacenttab) {
      return this.tabPresenter.createAdjacent(url, {
        openerTabId: openerId, active: !background
      });
    }
    return this.tabPresenter.create(url, {
      openerTabId: openerId, active: !background
    });
  }
}