diff options
Diffstat (limited to 'src/background/controllers')
-rw-r--r-- | src/background/controllers/CompletionController.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/background/controllers/CompletionController.ts b/src/background/controllers/CompletionController.ts new file mode 100644 index 0000000..313f38b --- /dev/null +++ b/src/background/controllers/CompletionController.ts @@ -0,0 +1,31 @@ +import { + ConsoleGetCompletionTypesResponse, + ConsoleRequestBookmarksResponse, ConsoleRequestHistoryResponse, ConsoleRequestSearchEnginesResponse +} from "../../shared/messages"; +import { injectable } from "tsyringe"; +import CompletionUseCase from "../completion/CompletionUseCase"; + +@injectable() +export default class CompletionController { + constructor( + private completionUseCase: CompletionUseCase, + ) { + } + + async getCompletionTypes(): Promise<ConsoleGetCompletionTypesResponse> { + return this.completionUseCase.getCompletionTypes(); + } + + async requestSearchEngines(query: string): Promise<ConsoleRequestSearchEnginesResponse> { + const items = await this.completionUseCase.requestSearchEngines(query); + return items.map(name => ({ title: name })); + } + + async requestBookmarks(query: string): Promise<ConsoleRequestBookmarksResponse> { + return this.completionUseCase.requestBookmarks(query); + } + + async requestHistory(query: string): Promise<ConsoleRequestHistoryResponse> { + return this.completionUseCase.requestHistory(query); + } +}
\ No newline at end of file |