aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/TabUseCase.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/usecases/TabUseCase.ts')
-rw-r--r--src/background/usecases/TabUseCase.ts36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/background/usecases/TabUseCase.ts b/src/background/usecases/TabUseCase.ts
index d930842..1615333 100644
--- a/src/background/usecases/TabUseCase.ts
+++ b/src/background/usecases/TabUseCase.ts
@@ -2,20 +2,24 @@ import TabPresenter from '../presenters/TabPresenter';
import BrowserSettingRepository from '../repositories/BrowserSettingRepository';
export default class TabUseCase {
+ private tabPresenter: TabPresenter;
+
+ private browserSettingRepository: BrowserSettingRepository;
+
constructor() {
this.tabPresenter = new TabPresenter();
this.browserSettingRepository = new BrowserSettingRepository();
}
- async close(force) {
+ async close(force: boolean): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
if (!force && tab.pinned) {
- return;
+ return Promise.resolve();
}
- return this.tabPresenter.remove([tab.id]);
+ return this.tabPresenter.remove([tab.id as number]);
}
- async closeRight() {
+ async closeRight(): Promise<any> {
let tabs = await this.tabPresenter.getAll();
tabs.sort((t1, t2) => t1.index - t2.index);
let index = tabs.findIndex(t => t.active);
@@ -25,42 +29,42 @@ export default class TabUseCase {
for (let i = index + 1; i < tabs.length; ++i) {
let tab = tabs[i];
if (!tab.pinned) {
- this.tabPresenter.remove(tab.id);
+ this.tabPresenter.remove([tab.id as number]);
}
}
}
- reopen() {
+ reopen(): Promise<any> {
return this.tabPresenter.reopen();
}
- async reload(cache) {
+ async reload(cache: boolean): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
- return this.tabPresenter.reload(tab.id, cache);
+ return this.tabPresenter.reload(tab.id as number, cache);
}
- async setPinned(pinned) {
+ async setPinned(pinned: boolean): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
- return this.tabPresenter.setPinned(tab.id, pinned);
+ return this.tabPresenter.setPinned(tab.id as number, pinned);
}
- async togglePinned() {
+ async togglePinned(): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
- return this.tabPresenter.setPinned(tab.id, !tab.pinned);
+ return this.tabPresenter.setPinned(tab.id as number, !tab.pinned);
}
- async duplicate() {
+ async duplicate(): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
- return this.tabPresenter.duplicate(tab.id);
+ return this.tabPresenter.duplicate(tab.id as number);
}
- async openPageSource() {
+ async openPageSource(): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
let url = 'view-source:' + tab.url;
return this.tabPresenter.create(url);
}
- async openHome(newTab) {
+ async openHome(newTab: boolean): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
let urls = await this.browserSettingRepository.getHomepageUrls();
if (urls.length === 1 && urls[0] === 'about:home') {