aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/histories.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/shared/completions/histories.js')
-rw-r--r--src/background/shared/completions/histories.js27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/background/shared/completions/histories.js b/src/background/shared/completions/histories.js
index a7d3d47..2d35401 100644
--- a/src/background/shared/completions/histories.js
+++ b/src/background/shared/completions/histories.js
@@ -61,23 +61,22 @@ const reduceByOrigin = (items, min) => {
return filtered;
};
-const getCompletions = (keyword) => {
- return browser.history.search({
+const getCompletions = async(keyword) => {
+ let historyItems = await browser.history.search({
text: keyword,
startTime: 0,
- }).then((historyItems) => {
- return [historyItems.map(item => [item, new URL(item.url)])]
- .map(filterEmptyTitle)
- .map(filterHttp)
- .map(filterClosedPath)
- .map(items => reduceByPathname(items, 10))
- .map(items => reduceByOrigin(items, 10))
- .map(items => items
- .sort((x, y) => x[0].visitCount < y[0].visitCount)
- .slice(0, 10)
- .map(item => item[0])
- )[0];
});
+ return [historyItems.map(item => [item, new URL(item.url)])]
+ .map(filterEmptyTitle)
+ .map(filterHttp)
+ .map(filterClosedPath)
+ .map(items => reduceByPathname(items, 10))
+ .map(items => reduceByOrigin(items, 10))
+ .map(items => items
+ .sort((x, y) => x[0].visitCount < y[0].visitCount)
+ .slice(0, 10)
+ .map(item => item[0])
+ )[0];
};
export { getCompletions };