diff options
Diffstat (limited to 'src/background/usecases')
-rw-r--r-- | src/background/usecases/ReadyFrameUseCase.ts | 18 | ||||
-rw-r--r-- | src/background/usecases/StartFindUseCase.ts | 12 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/background/usecases/ReadyFrameUseCase.ts b/src/background/usecases/ReadyFrameUseCase.ts new file mode 100644 index 0000000..81bee0c --- /dev/null +++ b/src/background/usecases/ReadyFrameUseCase.ts @@ -0,0 +1,18 @@ +import { inject, injectable } from "tsyringe"; +import ReadyFrameRepository from "../repositories/ReadyFrameRepository"; + +@injectable() +export default class ReadyFrameUseCase { + constructor( + @inject("ReadyFrameRepository") + private readonly frameRepository: ReadyFrameRepository + ) {} + + async addReadyFrame(tabId: number, frameId: number): Promise<void> { + return this.frameRepository.addFrameId(tabId, frameId); + } + + async clearReadyFrame(tabId: number): Promise<void> { + return this.frameRepository.clearFrameIds(tabId); + } +} diff --git a/src/background/usecases/StartFindUseCase.ts b/src/background/usecases/StartFindUseCase.ts index 066d930..a62462f 100644 --- a/src/background/usecases/StartFindUseCase.ts +++ b/src/background/usecases/StartFindUseCase.ts @@ -2,7 +2,7 @@ import { inject, injectable } from "tsyringe"; import ConsoleClient from "../infrastructures/ConsoleClient"; import FindRepositoryImpl from "../repositories/FindRepository"; import FindClient from "../clients/FindClient"; -import FramePresenter from "../presenters/FramePresenter"; +import ReadyFrameRepository from "../repositories/ReadyFrameRepository"; @injectable() export default class StartFindUseCase { @@ -13,8 +13,8 @@ export default class StartFindUseCase { private readonly findRepository: FindRepositoryImpl, @inject("ConsoleClient") private readonly consoleClient: ConsoleClient, - @inject("FramePresenter") - private readonly framePresenter: FramePresenter + @inject("ReadyFrameRepository") + private readonly frameRepository: ReadyFrameRepository ) {} async startFind(tabId: number, keyword?: string): Promise<void> { @@ -31,7 +31,11 @@ export default class StartFindUseCase { this.findRepository.setGlobalKeyword(keyword); - const frameIds = await this.framePresenter.getAllFrameIds(tabId); + const frameIds = await this.frameRepository.getFrameIds(tabId); + if (typeof frameIds === "undefined") { + // No frames are ready + return; + } for (const frameId of frameIds) { await this.findClient.clearSelection(tabId, frameId); } |