Skip to content

Commit

Permalink
Merge pull request #2080 from Sefaria/fix-monkey-conundrum
Browse files Browse the repository at this point in the history
Fix auto redicreciton of sourceless topic pages to sheets search results
  • Loading branch information
nsantacruz authored Oct 30, 2024
2 parents 1d2f19b + 69afcb0 commit f0f4961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions static/js/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,13 @@ const TopicPage = ({

useEffect( ()=> {
// hack to redirect to temporary sheet content on topics page for those topics that only have sheet content.
if (document.querySelector('.filter-content') && !document.querySelector('.filter-content').firstChild) {
if (!Sefaria.is_moderator && !topicData.isLoading && Object.keys(topicData.tabs).length == 0){
const interfaceIsHe = Sefaria.interfaceLang === "hebrew"
const topicPath = interfaceIsHe ? topicTitle.he : topicTitle.en;
const redirectUrl = `${document.location.origin}/search?q=${topicPath}&tab=sheet&tvar=1&tsort=relevance&stopics_${interfaceIsHe ? "he": "en"}Filters=${topicPath}&svar=1&ssort=relevance`
window.location.replace(redirectUrl);
}
},[loadedData])
},[topicData])

// Set up tabs and register incremental load hooks
const displayTabs = [];
Expand Down
2 changes: 1 addition & 1 deletion static/js/sefaria/sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ _media: {},
const allRefs = [...tabs["notable-sources"].refs, ...tabs.sources.refs];
tabs.sources.refs = allRefs;
}
if (Sefaria.is_moderator){
if (Sefaria.is_moderator && Object.keys(tabs).length > 0){
tabs["admin"] = {...tabs["sources"]};
tabs["admin"].title = {en: 'Admin', he: Sefaria.translation('hebrew', "Admin")};

Expand Down

0 comments on commit f0f4961

Please sign in to comment.