From 279acf92ad34e26567bf4ca65c641a7e0b4d2848 Mon Sep 17 00:00:00 2001 From: learner97 Date: Wed, 13 Nov 2024 11:56:21 -0700 Subject: [PATCH] made some changes to fix setup bugs --- frontend/pages/index.js | 24 ++++++++++-------------- frontend/specialAccess/setup.js | 6 +++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/frontend/pages/index.js b/frontend/pages/index.js index a952d197..df10bcce 100644 --- a/frontend/pages/index.js +++ b/frontend/pages/index.js @@ -19,24 +19,20 @@ const sdconverter = new showdown.Converter() * This page renders the home/landing page for sbh. */ function Home() { - const [frontPageText, setFrontPageText] = useState('Loading front page text...'); - // "SynBioHub is a design repository for people designing biological constructs. It enables DNA and protein designs to be uploaded, then facilitates sharing and viewing of such designs. SynBioHub also facilitates searching for information about existing useful parts and designs by combining data from a variety of sources." + const [frontPageText, setFrontPageText] = useState('Loading front page text...'); const token = useSelector(state => state.user.token); useEffect(() => { - const themeData = JSON.parse(localStorage.getItem('theme'), (key,value) => { - if (key === 'frontPageText') { - return sdconverter.makeHtml(value.replace(/\\n/g, '\n')); - } - return value; - }); - - if (themeData && themeData.frontPageText){ - setFrontPageText( - themeData.frontPageText - ); - } + // Attempt to retrieve frontPageText from localStorage + const themeData = JSON.parse(localStorage.getItem('theme') || '{}'); + if (themeData.frontPageText) { + // Convert Markdown to HTML if data is found + setFrontPageText(sdconverter.makeHtml(themeData.frontPageText.replace(/\\n/g, '\n'))); + } else { + // Set fallback text if data is not found + setFrontPageText('Welcome to SynBioHub! Refresh to ensure front page text is loaded.'); + } }, []); return ( diff --git a/frontend/specialAccess/setup.js b/frontend/specialAccess/setup.js index df2960de..c1a79c63 100644 --- a/frontend/specialAccess/setup.js +++ b/frontend/specialAccess/setup.js @@ -60,9 +60,9 @@ export default function Setup({ setInSetupMode }) { }, [color]); // change the url to the base url - useEffect(() => { - window.history.pushState({}, '', '/setup'); - }); + // useEffect(() => { + // window.history.pushState({}, '', '/setup'); + // }); return ( } publicPage={true}>