From d3a5927edebd908ed4e18eb2aba00bfe2aca5594 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 10 May 2019 14:22:18 -0400 Subject: [PATCH] Don't render inside a cloaked post --- .../initializers/initialize-ad-plugin.js.es6 | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/assets/javascripts/initializers/initialize-ad-plugin.js.es6 b/assets/javascripts/initializers/initialize-ad-plugin.js.es6 index e42915c..cd4c40a 100644 --- a/assets/javascripts/initializers/initialize-ad-plugin.js.es6 +++ b/assets/javascripts/initializers/initialize-ad-plugin.js.es6 @@ -7,24 +7,28 @@ export default { withPluginApi("0.1", api => { api.decorateWidget("post:after", dec => { if (dec.canConnectComponent) { + if (!dec.attrs.cloaked) { + return dec.connect({ + component: "post-bottom-ad", + context: "model" + }); + } + } else { + // Old way for backwards compatibility return dec.connect({ - component: "post-bottom-ad", + templateName: "connectors/post-bottom/discourse-adplugin", context: "model" }); } - - // Old way for backwards compatibility - return dec.connect({ - templateName: "connectors/post-bottom/discourse-adplugin", - context: "model" - }); }); }); - const messageBus = container.lookup('message-bus:main'); - if (!messageBus) { return; } + const messageBus = container.lookup("message-bus:main"); + if (!messageBus) { + return; + } - messageBus.subscribe("/site/house-creatives", function (houseAdsSettings) { + messageBus.subscribe("/site/house-creatives", function(houseAdsSettings) { Discourse.Site.currentProp("house_creatives", houseAdsSettings); }); }