From 94483920f2a32071505b913881eb7b342c910535 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 28 Mar 2021 11:02:05 +0900 Subject: Move classes to a correct directory --- src/background/clients/ConsoleFrameClient.ts | 15 +++++++++++++++ src/background/controllers/ConsoleController.ts | 2 +- src/background/controllers/ConsoleFrameClient.ts | 15 --------------- src/background/controllers/ConsoleUseCase.ts | 21 --------------------- src/background/di.ts | 2 +- src/background/usecases/ConsoleUseCase.ts | 21 +++++++++++++++++++++ 6 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 src/background/clients/ConsoleFrameClient.ts delete mode 100644 src/background/controllers/ConsoleFrameClient.ts delete mode 100644 src/background/controllers/ConsoleUseCase.ts create mode 100644 src/background/usecases/ConsoleUseCase.ts (limited to 'src') diff --git a/src/background/clients/ConsoleFrameClient.ts b/src/background/clients/ConsoleFrameClient.ts new file mode 100644 index 0000000..170566d --- /dev/null +++ b/src/background/clients/ConsoleFrameClient.ts @@ -0,0 +1,15 @@ +import * as messages from "../../shared/messages"; + +export default interface ConsoleFrameClient { + resize(tabId: number, width: number, height: number): Promise; +} + +export class ConsoleFrameClientImpl implements ConsoleFrameClient { + async resize(tabId: number, width: number, height: number): Promise { + await browser.tabs.sendMessage(tabId, { + type: messages.CONSOLE_RESIZE, + width, + height, + }); + } +} diff --git a/src/background/controllers/ConsoleController.ts b/src/background/controllers/ConsoleController.ts index 11ee09d..72b9b8e 100644 --- a/src/background/controllers/ConsoleController.ts +++ b/src/background/controllers/ConsoleController.ts @@ -1,5 +1,5 @@ import { injectable } from "tsyringe"; -import ConsoleUseCase from "./ConsoleUseCase"; +import ConsoleUseCase from "../usecases/ConsoleUseCase"; @injectable() export default class ConsoleController { diff --git a/src/background/controllers/ConsoleFrameClient.ts b/src/background/controllers/ConsoleFrameClient.ts deleted file mode 100644 index 170566d..0000000 --- a/src/background/controllers/ConsoleFrameClient.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as messages from "../../shared/messages"; - -export default interface ConsoleFrameClient { - resize(tabId: number, width: number, height: number): Promise; -} - -export class ConsoleFrameClientImpl implements ConsoleFrameClient { - async resize(tabId: number, width: number, height: number): Promise { - await browser.tabs.sendMessage(tabId, { - type: messages.CONSOLE_RESIZE, - width, - height, - }); - } -} diff --git a/src/background/controllers/ConsoleUseCase.ts b/src/background/controllers/ConsoleUseCase.ts deleted file mode 100644 index 556aaf8..0000000 --- a/src/background/controllers/ConsoleUseCase.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { inject, injectable } from "tsyringe"; -import ConsoleFrameClient from "./ConsoleFrameClient"; -import TabPresenter from "../presenters/TabPresenter"; - -@injectable() -export default class ConsoleUseCase { - constructor( - @inject("TabPresenter") - private readonly tabPresenter: TabPresenter, - @inject("ConsoleFrameClient") - private readonly consoleFrameClient: ConsoleFrameClient - ) {} - - async resize(width: number, height: number): Promise { - const tabId = (await this.tabPresenter.getCurrent()).id; - if (typeof tabId === "undefined") { - return; - } - return this.consoleFrameClient.resize(tabId, width, height); - } -} diff --git a/src/background/di.ts b/src/background/di.ts index 3c43d2d..a571c7d 100644 --- a/src/background/di.ts +++ b/src/background/di.ts @@ -18,7 +18,7 @@ import { BrowserSettingRepositoryImpl } from "./repositories/BrowserSettingRepos import { RepeatRepositoryImpl } from "./repositories/RepeatRepository"; import { ZoomPresenterImpl } from "./presenters/ZoomPresenter"; import { WindowPresenterImpl } from "./presenters/WindowPresenter"; -import { ConsoleFrameClientImpl } from "./controllers/ConsoleFrameClient"; +import { ConsoleFrameClientImpl } from "./clients/ConsoleFrameClient"; container.register("LocalSettingRepository", { useClass: LocalSettingRepository, diff --git a/src/background/usecases/ConsoleUseCase.ts b/src/background/usecases/ConsoleUseCase.ts new file mode 100644 index 0000000..329e4ee --- /dev/null +++ b/src/background/usecases/ConsoleUseCase.ts @@ -0,0 +1,21 @@ +import { inject, injectable } from "tsyringe"; +import ConsoleFrameClient from "../clients/ConsoleFrameClient"; +import TabPresenter from "../presenters/TabPresenter"; + +@injectable() +export default class ConsoleUseCase { + constructor( + @inject("TabPresenter") + private readonly tabPresenter: TabPresenter, + @inject("ConsoleFrameClient") + private readonly consoleFrameClient: ConsoleFrameClient + ) {} + + async resize(width: number, height: number): Promise { + const tabId = (await this.tabPresenter.getCurrent()).id; + if (typeof tabId === "undefined") { + return; + } + return this.consoleFrameClient.resize(tabId, width, height); + } +} -- cgit v1.2.3