aboutsummaryrefslogtreecommitdiff
path: root/src/background/completion/HistoryRepository.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/completion/HistoryRepository.ts')
-rw-r--r--src/background/completion/HistoryRepository.ts28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/background/completion/HistoryRepository.ts b/src/background/completion/HistoryRepository.ts
index 1cfaf1b..5eb3a2b 100644
--- a/src/background/completion/HistoryRepository.ts
+++ b/src/background/completion/HistoryRepository.ts
@@ -1,32 +1,8 @@
-import * as filters from "./filters";
-import { injectable } from "tsyringe";
-
export type HistoryItem = {
title: string
url: string
}
-const COMPLETION_ITEM_LIMIT = 10;
-
-@injectable()
-export default class HistoryRepository {
- async queryHistories(keywords: string): Promise<HistoryItem[]> {
- const items = await browser.history.search({
- text: keywords,
- startTime: 0,
- });
-
- return [items]
- .map(filters.filterBlankTitle)
- .map(filters.filterHttp)
- .map(filters.filterByTailingSlash)
- .map(pages => filters.filterByPathname(pages, COMPLETION_ITEM_LIMIT))
- .map(pages => filters.filterByOrigin(pages, COMPLETION_ITEM_LIMIT))[0]
- .sort((x, y) => Number(y.visitCount) - Number(x.visitCount))
- .slice(0, COMPLETION_ITEM_LIMIT)
- .map(item => ({
- title: item.title!!,
- url: item.url!!,
- }))
- }
+export default interface HistoryRepository {
+ queryHistories(keywords: string): Promise<HistoryItem[]>;
}