mirror of
https://github.com/discourse/discourse.git
synced 2025-01-20 16:59:29 +08:00
REFACTOR: Remove Discourse.SiteSettings
from lib:search
This commit is contained in:
parent
aa2eea7729
commit
0bf28e418f
|
@ -89,7 +89,7 @@ export default Controller.extend({
|
|||
|
||||
@discourseComputed("q")
|
||||
searchActive(q) {
|
||||
return isValidSearchTerm(q);
|
||||
return isValidSearchTerm(q, this.siteSettings);
|
||||
},
|
||||
|
||||
@discourseComputed("q")
|
||||
|
@ -209,7 +209,7 @@ export default Controller.extend({
|
|||
|
||||
this.set("invalidSearch", false);
|
||||
const searchTerm = this.searchTerm;
|
||||
if (!isValidSearchTerm(searchTerm)) {
|
||||
if (!isValidSearchTerm(searchTerm, this.siteSettings)) {
|
||||
this.set("invalidSearch", true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -185,11 +185,9 @@ export function getSearchKey(args) {
|
|||
);
|
||||
}
|
||||
|
||||
export function isValidSearchTerm(searchTerm) {
|
||||
export function isValidSearchTerm(searchTerm, siteSettings) {
|
||||
if (searchTerm) {
|
||||
return (
|
||||
searchTerm.trim().length >= Discourse.SiteSettings.min_search_term_length
|
||||
);
|
||||
return searchTerm.trim().length >= siteSettings.min_search_term_length;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -226,7 +224,7 @@ export function applySearchAutocomplete(
|
|||
)
|
||||
);
|
||||
|
||||
if (Discourse.SiteSettings.enable_mentions) {
|
||||
if (siteSettings.enable_mentions) {
|
||||
$input.autocomplete(
|
||||
_.merge(
|
||||
{
|
||||
|
|
|
@ -46,8 +46,8 @@ export default DiscourseRoute.extend({
|
|||
return cached.data.model;
|
||||
}
|
||||
|
||||
return PreloadStore.getAndRemove("search", function() {
|
||||
if (isValidSearchTerm(params.q)) {
|
||||
return PreloadStore.getAndRemove("search", () => {
|
||||
if (isValidSearchTerm(params.q, this.siteSettings)) {
|
||||
return ajax("/search", { data: args });
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -40,7 +40,7 @@ const SearchHelper = {
|
|||
const searchContext = contextEnabled ? widget.searchContext() : null;
|
||||
const fullSearchUrl = widget.fullSearchUrl();
|
||||
|
||||
if (!isValidSearchTerm(term)) {
|
||||
if (!isValidSearchTerm(term, widget.siteSettings)) {
|
||||
searchData.noResults = true;
|
||||
searchData.results = [];
|
||||
searchData.loading = false;
|
||||
|
@ -298,7 +298,7 @@ export default createWidget("search-menu", {
|
|||
},
|
||||
|
||||
fullSearch() {
|
||||
if (!isValidSearchTerm(searchData.term)) {
|
||||
if (!isValidSearchTerm(searchData.term, this.siteSettings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user