Skip to content

Commit

Permalink
Merge pull request #589 from nwplus/fix-application-whitescreen
Browse files Browse the repository at this point in the history
  • Loading branch information
martincai8 authored Jul 15, 2024
2 parents 65ecb9c + f1979ed commit 9608ccb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/utility/HackerApplicationContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,25 @@ export const uploadWaiverToStorage = async (userId, file) => {

export function HackerApplicationProvider({ children }) {
const { user } = useAuth()
const [application, setApplication] = useState(HACKER_APPLICATION_TEMPLATE)
const [application, setApplication] = useState(null)
const [, setUpdated] = useState(false)
const [applicationOpen, setApplicationOpen] = useState(null)
const applicationRef = useRef()
const { dbHackathonName } = useHackathon()
const [isLoading, setIsLoading] = useState(true)

/**Initialize retrieval of hacker application */
useEffect(() => {
const retrieveApplication = async () => {
if (!user) return
if (!user) {
setIsLoading(false)
return
}
const app = await getUserApplication(user.uid, dbHackathonName)
fillMissingProperties(app, HACKER_APPLICATION_TEMPLATE)
setApplication(app)
setUpdated(false)
setIsLoading(false)
analytics.logEvent(ANALYTICS_EVENTS.AccessApplication, { userId: user.uid })
}
retrieveApplication()
Expand Down Expand Up @@ -158,7 +163,7 @@ export function HackerApplicationProvider({ children }) {
})
}, [])

if (applicationOpen === null || application === undefined) {
if (isLoading || applicationOpen === null || application === null) {
return null
}

Expand Down

0 comments on commit 9608ccb

Please sign in to comment.