aboutsummaryrefslogtreecommitdiff
path: root/src/background/completion/impl/BookmarkRepositoryImpl.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-04-03 09:27:33 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-04-12 22:11:07 +0900
commit69dd47fccd7be7180e932cdfa548bfd08d4d1645 (patch)
tree6f94428f2ac3693d3b993048f69d51f93f49e7f2 /src/background/completion/impl/BookmarkRepositoryImpl.ts
parentd80d0f87b82ba4bd74ed9b2bb7354421a28a11b3 (diff)
Revert PrefetchAndCache
Diffstat (limited to 'src/background/completion/impl/BookmarkRepositoryImpl.ts')
-rw-r--r--src/background/completion/impl/BookmarkRepositoryImpl.ts25
1 files changed, 1 insertions, 24 deletions
diff --git a/src/background/completion/impl/BookmarkRepositoryImpl.ts b/src/background/completion/impl/BookmarkRepositoryImpl.ts
index ed6c5a6..0c95cf7 100644
--- a/src/background/completion/impl/BookmarkRepositoryImpl.ts
+++ b/src/background/completion/impl/BookmarkRepositoryImpl.ts
@@ -1,21 +1,9 @@
import BookmarkRepository, { BookmarkItem } from "../BookmarkRepository";
-import { HistoryItem } from "../HistoryRepository";
-import PrefetchAndCache from "./PrefetchAndCache";
const COMPLETION_ITEM_LIMIT = 10;
export default class CachedBookmarkRepository implements BookmarkRepository {
- private bookmarkCache: PrefetchAndCache<BookmarkItem>;
-
- constructor() {
- this.bookmarkCache = new PrefetchAndCache(this.getter, this.filter, 10);
- }
-
- queryBookmarks(query: string): Promise<BookmarkItem[]> {
- return this.bookmarkCache.get(query);
- }
-
- private async getter(query: string): Promise<BookmarkItem[]> {
+ async queryBookmarks(query: string): Promise<BookmarkItem[]> {
const items = await browser.bookmarks.search({ query });
return items
.filter((item) => item.title && item.title.length > 0)
@@ -35,15 +23,4 @@ export default class CachedBookmarkRepository implements BookmarkRepository {
url: item.url!,
}));
}
-
- private filter(items: HistoryItem[], query: string) {
- return items.filter((item) => {
- return query.split(" ").every((keyword) => {
- return (
- item.title.toLowerCase().includes(keyword.toLowerCase()) ||
- item.url!.includes(keyword)
- );
- });
- });
- }
}