Files
discourse-adplugin/assets/javascripts/discourse/components/ad-component.js.es6
T

30 lines
684 B
JavaScript
Raw Normal View History

2019-04-18 14:10:56 -04:00
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
2019-04-18 17:52:59 -04:00
@computed("currentUser.groups")
showToGroups(groups) {
2019-04-18 14:10:56 -04:00
const currentUser = Discourse.User.current();
if (
!currentUser ||
!groups ||
!this.siteSettings.no_ads_for_groups ||
this.siteSettings.no_ads_for_groups.length === 0
) {
return true;
}
const noAdsGroupNames = this.siteSettings.no_ads_for_groups.split("|");
return !groups.any(group => noAdsGroupNames.includes(group.name));
2019-04-18 17:52:59 -04:00
},
isNthPost(n) {
if (n && n > 0) {
return this.get("postNumber") % n === 0;
} else {
return false;
}
2019-04-18 14:10:56 -04:00
}
});