diff options
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) { |