FEATURE: option to disable ads on personal messages

Use the new setting "no ads for personal messages".
This commit is contained in:
Neil Lalonde 2019-06-27 14:13:51 -04:00
parent 2ba276b0fb
commit ad939a851a
3 changed files with 23 additions and 3 deletions

View File

@ -28,6 +28,11 @@ export default Ember.Component.extend({
}
},
@computed("router.currentRoute.parent.attributes.archetype")
isPersonalMessage(topicType) {
return topicType === "private_message";
},
@computed("currentUser.groups")
showToGroups(groups) {
const currentUser = Discourse.User.current();
@ -49,8 +54,18 @@ export default Ember.Component.extend({
return !groupNames.any(g => noAdsGroupNames.includes(g));
},
@computed("currentCategoryId", "topicTagsDisableAds", "topicListTag")
showOnCurrentPage(categoryId, topicTagsDisableAds, topicListTag) {
@computed(
"currentCategoryId",
"topicTagsDisableAds",
"topicListTag",
"isPersonalMessage"
)
showOnCurrentPage(
categoryId,
topicTagsDisableAds,
topicListTag,
isPersonalMessage
) {
return (
!topicTagsDisableAds &&
(!categoryId ||
@ -60,7 +75,8 @@ export default Ember.Component.extend({
.includes(categoryId.toString())) &&
(!topicListTag ||
!this.siteSettings.no_ads_for_tags ||
!this.siteSettings.no_ads_for_tags.split("|").includes(topicListTag))
!this.siteSettings.no_ads_for_tags.split("|").includes(topicListTag)) &&
(!isPersonalMessage || !this.siteSettings.no_ads_for_personal_messages)
);
},

View File

@ -1,5 +1,6 @@
en:
site_settings:
no_ads_for_personal_messages: "Don't show ads when viewing personal messages"
no_ads_for_groups: "Don't show ads to users in these groups."
no_ads_for_categories: "Don't show ads on topic list and topic pages belonging to these categories."
no_ads_for_tags: "Don't show ads on topic list and topic pages belonging to these tags."

View File

@ -1,4 +1,7 @@
ad_plugin:
no_ads_for_personal_messages:
client: true
default: true
no_ads_for_groups:
client: true
default: ""