Skip to content

Commit

Permalink
fw-5179, fix refresh error (#185)
Browse files Browse the repository at this point in the history
* Move NavBar home buttons into loading container
* Ensure siteLoading is false until siteStore is ready
  • Loading branch information
sarahfirstvoices authored Nov 7, 2023
1 parent 51452a5 commit 60c3bd6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
46 changes: 23 additions & 23 deletions src/components/NavBar/NavBarPresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ function NavBarPresentation({
<nav id="NavBar" className="relative z-10" role="navigation">
<div className="bg-fv-charcoal max-w-screen-2xl mx-auto px-2 lg:px-6 xl:px-16">
<div className="h-16 flex justify-between items-center py-1 space-x-2 lg:space-x-4">
{/* Home Links */}
<div className="flex items-center">
<div
className={`${
isHome ? '' : 'hidden'
} md:flex items-center text-white`}
>
<span className="sr-only">FirstVoices Logo</span>
<Link to="/">{fvlogo}</Link>
</div>
<div className="w-16 text-white text-sm leading-tight text-center mr-2">
Beta Version
</div>
{!isHome && (
<Link
className="h-9 text-white flex items-center group bg-fv-charcoal rounded-lg text-lg font-medium hover:text-gray-100"
to={`/${site?.sitename}/`}
>
<span className="sr-only">{site?.title}</span>
{getIcon('Home', 'fill-current h-full w-auto')}
</Link>
)}
</div>
{!siteLoading && (
<>
{/* Home Links */}
<div className="flex items-center">
<div
className={`${
isHome ? '' : 'hidden'
} md:flex items-center text-white`}
>
<span className="sr-only">FirstVoices Logo</span>
<Link to="/">{fvlogo}</Link>
</div>
<div className="w-16 text-white text-sm leading-tight text-center mr-2">
Beta Version
</div>
{!isHome && (
<Link
className="h-9 text-white flex items-center group bg-fv-charcoal rounded-lg text-lg font-medium hover:text-gray-100"
to={`/${site?.sitename}/`}
>
<span className="sr-only">{site?.title}</span>
{getIcon('Home', 'fill-current h-full w-auto')}
</Link>
)}
</div>
{/* Menus */}
<div id="NavMenus" className="hidden lg:flex xl:space-x-6 ">
{menuData?.dictionary && generateMenu(menuData?.dictionary)}
Expand Down
7 changes: 4 additions & 3 deletions src/components/Site/SiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import i18next from 'i18next'
// FPCC
import { useImmersion } from 'common/dataHooks/useImmersion'
import { useSite } from 'common/dataHooks/useSites'
import { useSiteDispatch } from 'context/SiteContext'
import { useSiteDispatch, useSiteStore } from 'context/SiteContext'

function SiteData() {
const navigate = useNavigate()
Expand All @@ -15,7 +15,8 @@ function SiteData() {
// --------------------------------
// Get Language Site data
// --------------------------------
const { isLoading, error, data } = useSite()
const { isLoading, error, data } = useSite() // site data request, to put in the site store
const { site } = useSiteStore() // site store, to validate when it is ready for use

useEffect(() => {
if (isLoading === false && error === null) {
Expand Down Expand Up @@ -61,7 +62,7 @@ function SiteData() {
}, [immersionIsLoading, immersionError, immersionData])

return {
siteLoading: isLoading || data?.id?.length < 1,
siteLoading: isLoading || site?.id?.length < 1,
}
}

Expand Down

0 comments on commit 60c3bd6

Please sign in to comment.