Skip to content

Commit

Permalink
fix: first load for new ipns site redirects properly
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Feb 28, 2024
1 parent 3071332 commit 4fb8357
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import React, { useContext } from 'react'
import React, { useContext, useEffect } from 'react'
import Config from './components/config.tsx'
import { ConfigContext } from './context/config-context.tsx'
import HelperUi from './helper-ui.tsx'
import { isConfigPage } from './lib/is-config-page.ts'
import { isPathOrSubdomainRequest } from './lib/path-or-subdomain.ts'
import { isPathOrSubdomainRequest, findOriginIsolationRedirect } from './lib/path-or-subdomain.ts'
import RedirectPage from './redirectPage.tsx'

function App (): JSX.Element {
const { isConfigExpanded, setConfigExpanded } = useContext(ConfigContext)

useEffect(() => {
async function originEnforcement (): Promise<void> {
// enforce early when loaded before SW was registered
const originRedirect = await findOriginIsolationRedirect(window.location)
if (originRedirect !== null) {
window.location.replace(originRedirect)
}
}
void originEnforcement()
}, [])

if (isConfigPage()) {
setConfigExpanded(true)
return <Config />
Expand Down

1 comment on commit 4fb8357

@SgtPooki
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidel re-added this back cause I ran into this a few times.. definitely an improvement for users.

Please sign in to comment.