REFACTOR: Remove `Discourse.SiteSettings` from click tracking

REFACTOR: Remove Discourse.SiteSettings from click tracking

diff --git a/app/assets/javascripts/discourse/app/components/discourse-topic.js b/app/assets/javascripts/discourse/app/components/discourse-topic.js
index 7e222e2..93aa5fa 100644
--- a/app/assets/javascripts/discourse/app/components/discourse-topic.js
+++ b/app/assets/javascripts/discourse/app/components/discourse-topic.js
@@ -108,9 +108,7 @@ export default Component.extend(
       $(this.element).on(
         "click.discourse-redirect",
         ".cooked a, a.track-link",
-        function(e) {
-          return ClickTrack.trackClick(e);
-        }
+        e => ClickTrack.trackClick(e, this.siteSettings)
       );
 
       this.appEvents.on("discourse:focus-changed", this, "gotFocus");
diff --git a/app/assets/javascripts/discourse/app/components/links-redirect.js b/app/assets/javascripts/discourse/app/components/links-redirect.js
index 0ddd92b..17fce6a 100644
--- a/app/assets/javascripts/discourse/app/components/links-redirect.js
+++ b/app/assets/javascripts/discourse/app/components/links-redirect.js
@@ -5,8 +5,8 @@ export default Component.extend({
   didInsertElement() {
     this._super(...arguments);
 
-    $(this.element).on("click.discourse-redirect", "a", function(e) {
-      return ClickTrack.trackClick(e);
+    $(this.element).on("click.discourse-redirect", "a", e => {
+      return ClickTrack.trackClick(e, this.siteSettings);
     });
   },
 
diff --git a/app/assets/javascripts/discourse/app/components/user-stream.js b/app/assets/javascripts/discourse/app/components/user-stream.js
index aadd188..b102eaa 100644
--- a/app/assets/javascripts/discourse/app/components/user-stream.js
+++ b/app/assets/javascripts/discourse/app/components/user-stream.js
@@ -40,8 +40,8 @@ export default Component.extend(LoadMore, {
       "details.disabled",
       () => false
     );
-    $(this.element).on("click.discourse-redirect", ".excerpt a", function(e) {
-      return ClickTrack.trackClick(e);
+    $(this.element).on("click.discourse-redirect", ".excerpt a", e => {
+      return ClickTrack.trackClick(e, this.siteSettings);
     });
   }),
 
diff --git a/app/assets/javascripts/discourse/app/lib/click-track.js b/app/assets/javascripts/discourse/app/lib/click-track.js
index d3a3744..c408da1 100644
--- a/app/assets/javascripts/discourse/app/lib/click-track.js
+++ b/app/assets/javascripts/discourse/app/lib/click-track.js
@@ -35,7 +35,7 @@ export function isValidLink($link) {
 }
 
 export default {
-  trackClick(e) {
+  trackClick(e, siteSettings) {
     // right clicks are not tracked
     if (e.which === 3) {
       return true;
@@ -65,7 +65,8 @@ export default {
     if ($link.hasClass("attachment")) {
       // Warn the user if they cannot download the file.
       if (
-        Discourse.SiteSettings.prevent_anons_from_downloading_files &&
+        siteSettings &&
+        siteSettings.prevent_anons_from_downloading_files &&
         !User.current()
       ) {
         bootbox.alert(I18n.t("post.errors.attachment_download_requires_login"));

GitHub sha: aa2eea77

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