aboutsummaryrefslogtreecommitdiff
path: root/src/background/completion/OpenCompletionUseCase.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/completion/OpenCompletionUseCase.ts')
-rw-r--r--src/background/completion/OpenCompletionUseCase.ts48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/background/completion/OpenCompletionUseCase.ts b/src/background/completion/OpenCompletionUseCase.ts
index 1b63e7c..e678c2f 100644
--- a/src/background/completion/OpenCompletionUseCase.ts
+++ b/src/background/completion/OpenCompletionUseCase.ts
@@ -5,38 +5,39 @@ import BookmarkRepository from "./BookmarkRepository";
import HistoryRepository from "./HistoryRepository";
export type BookmarkItem = {
- title: string
- url: string
-}
+ title: string;
+ url: string;
+};
export type HistoryItem = {
- title: string
- url: string
-}
+ title: string;
+ url: string;
+};
@injectable()
export default class OpenCompletionUseCase {
constructor(
- @inject('BookmarkRepository') private bookmarkRepository: BookmarkRepository,
- @inject('HistoryRepository') private historyRepository: HistoryRepository,
- @inject("CachedSettingRepository") private cachedSettingRepository: CachedSettingRepository,
- ) {
- }
+ @inject("BookmarkRepository")
+ private bookmarkRepository: BookmarkRepository,
+ @inject("HistoryRepository") private historyRepository: HistoryRepository,
+ @inject("CachedSettingRepository")
+ private cachedSettingRepository: CachedSettingRepository
+ ) {}
async getCompletionTypes(): Promise<CompletionType[]> {
const settings = await this.cachedSettingRepository.get();
const types: CompletionType[] = [];
for (const c of settings.properties.complete) {
switch (c) {
- case 's':
- types.push(CompletionType.SearchEngines);
- break;
- case 'h':
- types.push(CompletionType.History);
- break;
- case 'b':
- types.push(CompletionType.Bookmarks);
- break;
+ case "s":
+ types.push(CompletionType.SearchEngines);
+ break;
+ case "h":
+ types.push(CompletionType.History);
+ break;
+ case "b":
+ types.push(CompletionType.Bookmarks);
+ break;
}
// ignore invalid characters in the complete property
}
@@ -45,8 +46,9 @@ export default class OpenCompletionUseCase {
async requestSearchEngines(query: string): Promise<string[]> {
const settings = await this.cachedSettingRepository.get();
- return Object.keys(settings.search.engines)
- .filter(key => key.startsWith(query))
+ return Object.keys(settings.search.engines).filter((key) =>
+ key.startsWith(query)
+ );
}
requestBookmarks(query: string): Promise<BookmarkItem[]> {
@@ -56,4 +58,4 @@ export default class OpenCompletionUseCase {
requestHistory(query: string): Promise<HistoryItem[]> {
return this.historyRepository.queryHistories(query);
}
-} \ No newline at end of file
+}