diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-26 11:54:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 11:54:11 +0900 |
commit | 9154972485c24a5a90782cef17f75b3a79a13774 (patch) | |
tree | 4bc3d608f498176f50a74ca7fc03d2d501ac7920 /src/background/usecases/StartFindUseCase.ts | |
parent | cbf4b37bd0d5ba277d6400ed460d6a086ae1d7bb (diff) | |
parent | 91d4712e676782bb58fd7eb03fdc1f85111fca04 (diff) |
Merge pull request #1264 from ueokande/fix-establish-connection-issue
Search a content from frames successfully loaded
Diffstat (limited to 'src/background/usecases/StartFindUseCase.ts')
-rw-r--r-- | src/background/usecases/StartFindUseCase.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/background/usecases/StartFindUseCase.ts b/src/background/usecases/StartFindUseCase.ts index 066d930..6aad962 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,21 +31,20 @@ 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); } - for (let framePos = 0; framePos < frameIds.length; ++framePos) { - const found = await this.findClient.findNext( - tabId, - frameIds[framePos], - keyword - ); + for (const frameId of frameIds) { + const found = await this.findClient.findNext(tabId, frameId, keyword); if (found) { await this.findRepository.setLocalState(tabId, { - frameIds, - framePos, + frameId, keyword, }); await this.consoleClient.showInfo(tabId, "Pattern found: " + keyword); |