mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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")
|
@discourseComputed("q")
|
||||||
searchActive(q) {
|
searchActive(q) {
|
||||||
return isValidSearchTerm(q);
|
return isValidSearchTerm(q, this.siteSettings);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("q")
|
@discourseComputed("q")
|
||||||
@ -209,7 +209,7 @@ export default Controller.extend({
|
|||||||
|
|
||||||
this.set("invalidSearch", false);
|
this.set("invalidSearch", false);
|
||||||
const searchTerm = this.searchTerm;
|
const searchTerm = this.searchTerm;
|
||||||
if (!isValidSearchTerm(searchTerm)) {
|
if (!isValidSearchTerm(searchTerm, this.siteSettings)) {
|
||||||
this.set("invalidSearch", true);
|
this.set("invalidSearch", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +185,9 @@ export function getSearchKey(args) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidSearchTerm(searchTerm) {
|
export function isValidSearchTerm(searchTerm, siteSettings) {
|
||||||
if (searchTerm) {
|
if (searchTerm) {
|
||||||
return (
|
return searchTerm.trim().length >= siteSettings.min_search_term_length;
|
||||||
searchTerm.trim().length >= Discourse.SiteSettings.min_search_term_length
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,7 +224,7 @@ export function applySearchAutocomplete(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Discourse.SiteSettings.enable_mentions) {
|
if (siteSettings.enable_mentions) {
|
||||||
$input.autocomplete(
|
$input.autocomplete(
|
||||||
_.merge(
|
_.merge(
|
||||||
{
|
{
|
||||||
|
@ -46,8 +46,8 @@ export default DiscourseRoute.extend({
|
|||||||
return cached.data.model;
|
return cached.data.model;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PreloadStore.getAndRemove("search", function() {
|
return PreloadStore.getAndRemove("search", () => {
|
||||||
if (isValidSearchTerm(params.q)) {
|
if (isValidSearchTerm(params.q, this.siteSettings)) {
|
||||||
return ajax("/search", { data: args });
|
return ajax("/search", { data: args });
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -40,7 +40,7 @@ const SearchHelper = {
|
|||||||
const searchContext = contextEnabled ? widget.searchContext() : null;
|
const searchContext = contextEnabled ? widget.searchContext() : null;
|
||||||
const fullSearchUrl = widget.fullSearchUrl();
|
const fullSearchUrl = widget.fullSearchUrl();
|
||||||
|
|
||||||
if (!isValidSearchTerm(term)) {
|
if (!isValidSearchTerm(term, widget.siteSettings)) {
|
||||||
searchData.noResults = true;
|
searchData.noResults = true;
|
||||||
searchData.results = [];
|
searchData.results = [];
|
||||||
searchData.loading = false;
|
searchData.loading = false;
|
||||||
@ -298,7 +298,7 @@ export default createWidget("search-menu", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fullSearch() {
|
fullSearch() {
|
||||||
if (!isValidSearchTerm(searchData.term)) {
|
if (!isValidSearchTerm(searchData.term, this.siteSettings)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user