aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/TabUseCase.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-02 17:25:56 +0900
committerGitHub <noreply@github.com>2020-05-02 17:25:56 +0900
commit5df0537bcf65a341e79852b1b30379c73318529c (patch)
treeaee5efe52412855f620cb514a13a2c14373f27b7 /src/background/usecases/TabUseCase.ts
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
parent75abd90ecb8201ad845b266f96220d8adfe19b2d (diff)
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'src/background/usecases/TabUseCase.ts')
-rw-r--r--src/background/usecases/TabUseCase.ts29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/background/usecases/TabUseCase.ts b/src/background/usecases/TabUseCase.ts
index 418dde5..1439107 100644
--- a/src/background/usecases/TabUseCase.ts
+++ b/src/background/usecases/TabUseCase.ts
@@ -1,16 +1,15 @@
-import {inject, injectable} from 'tsyringe';
-import TabPresenter from '../presenters/TabPresenter';
-import WindowPresenter from '../presenters/WindowPresenter';
-import BrowserSettingRepository from '../repositories/BrowserSettingRepository';
+import { inject, injectable } from "tsyringe";
+import TabPresenter from "../presenters/TabPresenter";
+import WindowPresenter from "../presenters/WindowPresenter";
+import BrowserSettingRepository from "../repositories/BrowserSettingRepository";
@injectable()
export default class TabUseCase {
constructor(
- @inject('TabPresenter') private tabPresenter: TabPresenter,
+ @inject("TabPresenter") private tabPresenter: TabPresenter,
private windowPresenter: WindowPresenter,
- private browserSettingRepository: BrowserSettingRepository,
- ) {
- }
+ private browserSettingRepository: BrowserSettingRepository
+ ) {}
async close(force: boolean, selectLeft = false): Promise<any> {
const tab = await this.tabPresenter.getCurrent();
@@ -27,7 +26,7 @@ export default class TabUseCase {
async closeRight(): Promise<any> {
const tabs = await this.tabPresenter.getAll();
tabs.sort((t1, t2) => t1.index - t2.index);
- const index = tabs.findIndex(t => t.active);
+ const index = tabs.findIndex((t) => t.active);
if (index < 0) {
return;
}
@@ -65,16 +64,18 @@ export default class TabUseCase {
async openPageSource(): Promise<any> {
const tab = await this.tabPresenter.getCurrent();
- const url = 'view-source:' + tab.url;
+ const url = "view-source:" + tab.url;
return this.tabPresenter.create(url);
}
async openHome(newTab: boolean): Promise<any> {
const tab = await this.tabPresenter.getCurrent();
const urls = await this.browserSettingRepository.getHomepageUrls();
- if (urls.length === 1 && urls[0] === 'about:home') {
+ if (urls.length === 1 && urls[0] === "about:home") {
// eslint-disable-next-line max-len
- throw new Error('Cannot open Firefox Home (about:home) by WebExtensions, set your custom URLs');
+ throw new Error(
+ "Cannot open Firefox Home (about:home) by WebExtensions, set your custom URLs"
+ );
}
if (urls.length === 1 && !newTab) {
return this.tabPresenter.open(urls[0], tab.id);
@@ -85,7 +86,9 @@ export default class TabUseCase {
}
async openURL(
- url: string, newTab?: boolean, newWindow?: boolean,
+ url: string,
+ newTab?: boolean,
+ newWindow?: boolean
): Promise<void> {
if (newWindow) {
await this.windowPresenter.create(url);