diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-21 11:17:51 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-21 16:15:07 +0900 |
commit | fc5e6b2b410d6850278dd982990ce42552a3b1b2 (patch) | |
tree | 70035fa636d37dc16a6b2dc1ed192234f1e64e9b /src/background/usecases | |
parent | 890d93fe773ea5cde41d19125d4bad626e54059e (diff) |
Complete open histories and bookmarks
Diffstat (limited to 'src/background/usecases')
-rw-r--r-- | src/background/usecases/completions.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/background/usecases/completions.js b/src/background/usecases/completions.js index 21049d2..0bc34d1 100644 --- a/src/background/usecases/completions.js +++ b/src/background/usecases/completions.js @@ -27,8 +27,28 @@ export default class CompletionsInteractor { ); } - queryOpen() { - return Promise.resolve(Completions.empty()); + async queryOpen(name, keywords) { + let groups = []; + let histories = await this.completionRepository.queryHistories(keywords); + if (histories.length > 0) { + let items = histories.map(page => new CompletionItem({ + caption: page.title, + content: name + ' ' + page.url, + url: page.url + })); + groups.push(new CompletionGroup('History', items)); + } + + let bookmarks = await this.completionRepository.queryBookmarks(keywords); + if (bookmarks.length > 0) { + let items = bookmarks.map(page => new CompletionItem({ + caption: page.title, + content: name + ' ' + page.url, + url: page.url + })); + groups.push(new CompletionGroup('Bookmarks', items)); + } + return new Completions(groups); } queryBuffer(name, keywords) { |