diff options
Diffstat (limited to 'src/background/usecases/TabSelectUseCase.ts')
-rw-r--r-- | src/background/usecases/TabSelectUseCase.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/background/usecases/TabSelectUseCase.ts b/src/background/usecases/TabSelectUseCase.ts deleted file mode 100644 index 663ceb8..0000000 --- a/src/background/usecases/TabSelectUseCase.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { inject, injectable } from "tsyringe"; -import TabPresenter from "../presenters/TabPresenter"; - -@injectable() -export default class TabSelectUseCase { - constructor(@inject("TabPresenter") private tabPresenter: TabPresenter) {} - - async selectPrev(count: number): Promise<any> { - const tabs = await this.tabPresenter.getAll(); - if (tabs.length < 2) { - return; - } - const tab = tabs.find((t) => t.active); - if (!tab) { - return; - } - const select = (tab.index - count + tabs.length) % tabs.length; - return this.tabPresenter.select(tabs[select].id as number); - } - - async selectNext(count: number): Promise<any> { - const tabs = await this.tabPresenter.getAll(); - if (tabs.length < 2) { - return; - } - const tab = tabs.find((t) => t.active); - if (!tab) { - return; - } - const select = (tab.index + count) % tabs.length; - return this.tabPresenter.select(tabs[select].id as number); - } - - async selectFirst(): Promise<any> { - const tabs = await this.tabPresenter.getAll(); - return this.tabPresenter.select(tabs[0].id as number); - } - - async selectLast(): Promise<any> { - const tabs = await this.tabPresenter.getAll(); - return this.tabPresenter.select(tabs[tabs.length - 1].id as number); - } - - async selectPrevSelected(): Promise<any> { - const tabId = await this.tabPresenter.getLastSelectedId(); - if (tabId === null || typeof tabId === "undefined") { - return Promise.resolve(); - } - return this.tabPresenter.select(tabId); - } -} |