diff --git a/src/components/SearchSettings.vue b/src/components/SearchSettings.vue index ec9fde5..c78e8cd 100644 --- a/src/components/SearchSettings.vue +++ b/src/components/SearchSettings.vue @@ -23,6 +23,7 @@ { + let location = browsingOptions.query ? "/q/" + encodeURIComponent(browsingOptions.query) : "/"; + // because this is debounced, it's possible that two consecutive searches are performed with the same query + // i.e. user types "brain" and obtain results, then deletes one char "brai" and add one char back to "brain" + // in less than 1s + if (location !== this.$router.currentRoute.fullPath) { + return this.$router.push(location); + } + }).catch(swallowCancellation) + .catch(err => { + // because the function is debounced, the caller might never get resulting promise and ability to handle the error + console.error("Error while searching: " + err.message + ".", err); + this.setLastError(err); + }); + }, 1000) }; }, computed: { @@ -421,28 +444,11 @@ export default { } }, methods: { + flush: function(){ + this.search.flush() + }, formatDecimal, formatPercent, - /** - * Basically a browse with a debounce when the user is actively typing a query. - * @return {Promise|undefined} initially undefined, then a promise once the function has been invoked at least once - */ - search: debounce(function(browsingOptions) { - return this.browse(browsingOptions, true).then(() => { - let location = browsingOptions.query ? "/q/" + encodeURIComponent(browsingOptions.query) : "/"; - // because this is debounced, it's possible that two consecutive searches are performed with the same query - // i.e. user types "brain" and obtain results, then deletes one char "brai" and add one char back to "brain" - // in less than 1s - if (location !== this.$router.currentRoute.fullPath) { - return this.$router.push(location); - } - }).catch(swallowCancellation) - .catch(err => { - // because the function is debounced, the caller might never get resulting promise and ability to handle the error - console.error("Error while searching: " + err.message + ".", err); - this.setLastError(err); - }); - }, 1000), browse(browsingOptions, updateEverything) { // update available annotations and number of datasets let updateDatasetsPromise = this.updateDatasets(browsingOptions.query, browsingOptions.filter, browsingOptions.offset, browsingOptions.limit, browsingOptions.sort);