REFACTOR: Remove `Discourse.SiteSettings` from `lib:search`

REFACTOR: Remove Discourse.SiteSettings from lib:search

diff --git a/app/assets/javascripts/discourse/app/controllers/full-page-search.js b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
index 1183a8e..4531ce2 100644
--- a/app/assets/javascripts/discourse/app/controllers/full-page-search.js
+++ b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
@@ -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;
     }
diff --git a/app/assets/javascripts/discourse/app/lib/search.js b/app/assets/javascripts/discourse/app/lib/search.js
index b26e173..02b7843 100644
--- a/app/assets/javascripts/discourse/app/lib/search.js
+++ b/app/assets/javascripts/discourse/app/lib/search.js
@@ -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(
         {
diff --git a/app/assets/javascripts/discourse/app/routes/full-page-search.js b/app/assets/javascripts/discourse/app/routes/full-page-search.js
index d2abf0d..65598a0 100644
--- a/app/assets/javascripts/discourse/app/routes/full-page-search.js
+++ b/app/assets/javascripts/discourse/app/routes/full-page-search.js
@@ -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;
diff --git a/app/assets/javascripts/discourse/app/widgets/search-menu.js b/app/assets/javascripts/discourse/app/widgets/search-menu.js
index 50f89a9..163cfcd 100644
--- a/app/assets/javascripts/discourse/app/widgets/search-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/search-menu.js
@@ -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;
     }
 

GitHub sha: 0bf28e41

This commit appears in #10290 which was merged by eviltrout.