diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-04-09 10:38:37 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 10:38:37 +0900 |
commit | 1656d52d2cefb3846d968c6117484e6aefe7dabe (patch) | |
tree | ab58a99b832d2571e2168f2ee0e328bc12d9580e /src/background/repositories | |
parent | c6c2da8547891b50aef2f08e5f36d258183831ff (diff) | |
parent | 5176643e64d8f4a6be5fc73f0eb48dc65322e496 (diff) |
Merge pull request #730 from ueokande/refactor-console-and-completion
Refactor console and completions
Diffstat (limited to 'src/background/repositories')
-rw-r--r-- | src/background/repositories/CompletionsRepository.ts | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/background/repositories/CompletionsRepository.ts b/src/background/repositories/CompletionsRepository.ts deleted file mode 100644 index dfecff0..0000000 --- a/src/background/repositories/CompletionsRepository.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { injectable } from 'tsyringe'; - -type Tab = browser.tabs.Tab; -type BookmarkTreeNode = browser.bookmarks.BookmarkTreeNode; - -@injectable() -export default class CompletionsRepository { - async queryBookmarks(keywords: string): Promise<BookmarkTreeNode[]> { - const items = await browser.bookmarks.search({ query: keywords }); - return items.filter((item) => { - if (!item.url) { - return false; - } - let url = undefined; - try { - url = new URL(item.url); - } catch (e) { - return false; - } - return item.type === 'bookmark' && url.protocol !== 'place:'; - }); - } - - queryHistories(keywords: string): Promise<browser.history.HistoryItem[]> { - return browser.history.search({ - text: keywords, - startTime: 0, - }); - } - - async queryTabs(keywords: string, excludePinned: boolean): Promise<Tab[]> { - const tabs = await browser.tabs.query({ currentWindow: true }); - return tabs.filter((t) => { - return t.url && t.url.toLowerCase().includes(keywords.toLowerCase()) || - t.title && t.title.toLowerCase().includes(keywords.toLowerCase()); - }).filter((t) => { - return !(excludePinned && t.pinned); - }); - } -} |