porting autocomplete to algolia, WIP, #203

This commit is contained in:
azivner
2018-11-07 00:23:50 +01:00
parent 57e9850ca6
commit 3c23d7085e
5 changed files with 92 additions and 20 deletions

View File

@@ -1,13 +1,13 @@
import server from "./server.js";
import noteDetailService from "./note_detail.js";
async function autocompleteSource(request, response) {
async function autocompleteSource(term, cb) {
const result = await server.get('autocomplete'
+ '?query=' + encodeURIComponent(request.term)
+ '?query=' + encodeURIComponent(term)
+ '&currentNoteId=' + noteDetailService.getCurrentNoteId());
if (result.length > 0) {
response(result.map(row => {
cb(result.map(row => {
return {
label: row.label,
value: row.label + ' (' + row.value + ')'
@@ -15,7 +15,7 @@ async function autocompleteSource(request, response) {
}));
}
else {
response([{
cb([{
label: "No results",
value: "No results"
}]);