mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Fix instantiating type field with value from URL query parameter
- Populate via `.then` after enabled search types in dropdown are populated - Call to `/config` API is async and will usually complete after the value of type field is set from url - So value of type field would earlier be overridden when search types dropdown is populated after the call to `/config` API completes
This commit is contained in:
@@ -93,12 +93,13 @@
|
|||||||
.filter(type => data["content-type"].hasOwnProperty(type) && data["content-type"][type])
|
.filter(type => data["content-type"].hasOwnProperty(type) && data["content-type"][type])
|
||||||
.map(type => `<option value="${type}">${type.slice(0,1).toUpperCase() + type.slice(1)}</option>`)
|
.map(type => `<option value="${type}">${type.slice(0,1).toUpperCase() + type.slice(1)}</option>`)
|
||||||
.join('');
|
.join('');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// Set type field to search type passed in URL query parameter, if valid
|
||||||
|
var type_via_url = new URLSearchParams(window.location.search).get("t");
|
||||||
|
if (type_via_url && possible_search_types.includes(type_via_url))
|
||||||
|
document.getElementById("type").value = type_via_url;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set type field to search type passed in URL query parameter, if valid
|
|
||||||
var type_via_url = new URLSearchParams(window.location.search).get("t");
|
|
||||||
if (type_via_url && type_via_url in possible_search_types)
|
|
||||||
document.getElementById("type").value = type_via_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
@@ -107,9 +108,8 @@
|
|||||||
|
|
||||||
// Fill query field with value passed in URL query parameters, if any.
|
// Fill query field with value passed in URL query parameters, if any.
|
||||||
var query_via_url = new URLSearchParams(window.location.search).get("q");
|
var query_via_url = new URLSearchParams(window.location.search).get("q");
|
||||||
if (query_via_url) {
|
if (query_via_url)
|
||||||
document.getElementById("query").value = query_via_url;
|
document.getElementById("query").value = query_via_url;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user