From f823b9574c37c5229f813e7416ee4a1dfd9caa47 Mon Sep 17 00:00:00 2001 From: Nissa Mai-Rose Date: Fri, 8 Apr 2022 14:17:16 -0400 Subject: [PATCH] show in app ads on topic pages --- static/js/ReaderApp.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/ReaderApp.jsx b/static/js/ReaderApp.jsx index 824a5ed305..db78ec62f1 100644 --- a/static/js/ReaderApp.jsx +++ b/static/js/ReaderApp.jsx @@ -1790,7 +1790,17 @@ class ReaderApp extends Component { } getUserContext() { - const refs = this.state.panels.map(panel => panel.currentlyVisibleRef || panel.bookRef || panel.navigationCategories || panel.navigationTopic).flat(); + const returnNullIfEmpty = (value) => { + if(Array.isArray(value)) { + if(value.length === 0) { + return null; + } else { + return value; + } + } + + } + const refs = this.state.panels.map(panel => panel.currentlyVisibleRef || panel.bookRef || returnNullIfEmpty(panel.navigationCategories) || panel.navigationTopic).flat(); const books = refs.map(ref => Sefaria.parseRef(ref).book); const triggers = refs.map(ref => Sefaria.refCategories(ref)) .concat(books)