aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/completions.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-10-08 10:46:07 +0900
committerGitHub <noreply@github.com>2018-10-08 10:46:07 +0900
commitcb3637ec74f5944b2558e373e5b6a8686725dba4 (patch)
tree188cd44723f0368de1c4ccb70960340dea10c520 /src/background/usecases/completions.js
parentf263e777ef3bf3aeff52ede881647f2e1aa308ea (diff)
parentbab8066af8eafec67448fb473f8c021d85ab06bd (diff)
Merge pull request #461 from ueokande/control-over-suggestions
Add complete property
Diffstat (limited to 'src/background/usecases/completions.js')
-rw-r--r--src/background/usecases/completions.js33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/background/usecases/completions.js b/src/background/usecases/completions.js
index 9385760..2dc71cc 100644
--- a/src/background/usecases/completions.js
+++ b/src/background/usecases/completions.js
@@ -36,18 +36,29 @@ export default class CompletionsInteractor {
}
async queryOpen(name, keywords) {
+ let settings = await this.settingRepository.get();
let groups = [];
- let engines = await this.querySearchEngineItems(name, keywords);
- if (engines.length > 0) {
- groups.push(new CompletionGroup('Search Engines', engines));
- }
- let histories = await this.queryHistoryItems(name, keywords);
- if (histories.length > 0) {
- groups.push(new CompletionGroup('History', histories));
- }
- let bookmarks = await this.queryBookmarkItems(name, keywords);
- if (bookmarks.length > 0) {
- groups.push(new CompletionGroup('Bookmarks', bookmarks));
+
+ for (let c of settings.properties.complete) {
+ if (c === 's') {
+ // eslint-disable-next-line no-await-in-loop
+ let engines = await this.querySearchEngineItems(name, keywords);
+ if (engines.length > 0) {
+ groups.push(new CompletionGroup('Search Engines', engines));
+ }
+ } else if (c === 'h') {
+ // eslint-disable-next-line no-await-in-loop
+ let histories = await this.queryHistoryItems(name, keywords);
+ if (histories.length > 0) {
+ groups.push(new CompletionGroup('History', histories));
+ }
+ } else if (c === 'b') {
+ // eslint-disable-next-line no-await-in-loop
+ let bookmarks = await this.queryBookmarkItems(name, keywords);
+ if (bookmarks.length > 0) {
+ groups.push(new CompletionGroup('Bookmarks', bookmarks));
+ }
+ }
}
return new Completions(groups);
}