OBR-hack: move AdsSticky up to make it load first

We are asking Outbrain to make it order-agnostic, but for now, we need to load the Sticky script first before the Banner script.

This is ugly code because the requirement is not obvious unless we put a bunch of comments, but I don't want to pollute `app/view.jsx`. Hopefully they can address this and we can revert in the coming days.
This commit is contained in:
infinite-persistence 2022-06-15 17:00:23 +08:00 committed by Thomas Zarebczan
parent 6c6aa7a117
commit e70ed61d4e
2 changed files with 2 additions and 3 deletions

View file

@ -543,6 +543,7 @@ function App(props: Props) {
/> />
) : ( ) : (
<React.Fragment> <React.Fragment>
<AdsSticky uri={uri} />
<Router uri={uri} embedLatestPath={embedLatestPath} /> <Router uri={uri} embedLatestPath={embedLatestPath} />
<ModalRouter /> <ModalRouter />
@ -560,8 +561,6 @@ function App(props: Props) {
)} )}
{getStatusNag()} {getStatusNag()}
</React.Suspense> </React.Suspense>
<AdsSticky uri={uri} />
</React.Fragment> </React.Fragment>
)} )}
</div> </div>

View file

@ -44,7 +44,7 @@ export default function AdsSticky(props: Props) {
// Global conditions aside, should the Sticky be shown for this path: // Global conditions aside, should the Sticky be shown for this path:
const inAllowedPath = shouldShowAdsForPath(location.pathname, isContentClaim, isChannelClaim, authenticated); const inAllowedPath = shouldShowAdsForPath(location.pathname, isContentClaim, isChannelClaim, authenticated);
// Final answer: // Final answer:
const shouldLoadSticky = shouldShowAds && inAllowedPath && !gScript && !inIFrame() && !platform.isMobile(); const shouldLoadSticky = shouldShowAds && !gScript && !inIFrame() && !platform.isMobile();
function shouldShowAdsForPath(pathname, isContentClaim, isChannelClaim, authenticated) { function shouldShowAdsForPath(pathname, isContentClaim, isChannelClaim, authenticated) {
// $FlowIssue: mixed type // $FlowIssue: mixed type