aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-21 11:17:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-07-21 16:15:07 +0900
commitfc5e6b2b410d6850278dd982990ce42552a3b1b2 (patch)
tree70035fa636d37dc16a6b2dc1ed192234f1e64e9b /src/background/usecases
parent890d93fe773ea5cde41d19125d4bad626e54059e (diff)
Complete open histories and bookmarks
Diffstat (limited to 'src/background/usecases')
-rw-r--r--src/background/usecases/completions.js24
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) {