REFACTOR: Remove `Discourse.SiteSettings` from click tracking

This commit is contained in:
Robin Ward 2020-07-22 11:32:03 -04:00
parent bc7dac852f
commit aa2eea7729
4 changed files with 8 additions and 9 deletions

View File

@ -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");

View File

@ -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);
});
},

View File

@ -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);
});
}),

View File

@ -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"));