Skip to content
Snippets Groups Projects
Commit 1817ba5b authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Remove debounce

parent 1be13cde
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
<script> <script>
import axios from "axios" import axios from "axios"
import debounce from "debounce"
export default { export default {
props: { props: {
...@@ -50,30 +49,6 @@ ...@@ -50,30 +49,6 @@
search: null, search: null,
select: null, select: null,
suggesting: null, suggesting: null,
debounced: debounce(function(q, self) {
self.loading = true
return axios.get(self.endpoint + 'suggest?', { params: {q: q,
dict: self.$parent.lang,
n: 9}} )
.then(
function(response) {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let hits = []
response.data.forEach((item, i) => {
let hit = {q: q, match: item[0], label: item[0], articles: []}
hit.lang = item[1]
hits.push(hit)
});
// whitespace necessary because duplicates aren't allowed in the dropdown
hits.push({q: q, label: q + ' '})
self.items = hits
}
self.loading = false
})
}, 100)
} }
}, },
watch: { watch: {
...@@ -136,7 +111,29 @@ ...@@ -136,7 +111,29 @@
this.items[0] = {q: q, label: q} this.items[0] = {q: q, label: q}
} }
} }
this.debounced(q, this) let self = this
axios.get(self.endpoint + 'suggest?', { params: {q: q,
dict: self.$parent.lang,
n: 9}} )
.then(
function(response) {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let hits = []
response.data.forEach((item, i) => {
let hit = {q: q, match: item[0], label: item[0], articles: []}
hit.lang = item[1]
hits.push(hit)
});
// whitespace necessary because duplicates aren't allowed in the dropdown
hits.push({q: q, label: q + ' '})
self.items = hits
}
self.loading = false
})
}, },
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment