mirror of
https://github.com/wisplite/raster.git
synced 2026-05-01 06:32:44 -05:00
small updates, for some reason it thinks every file is modified
This commit is contained in:
+54
-54
@@ -1,54 +1,54 @@
|
||||
import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-dom'
|
||||
import Viewer from './viewer'
|
||||
import Gallery from './gallery'
|
||||
import Login from './account/login'
|
||||
import { getServerUrl } from './hooks/getConstants'
|
||||
import { useEffect } from 'react'
|
||||
import CreateRootUser from './account/createRoot'
|
||||
import { AccountProvider } from './contexts/useAccount'
|
||||
import { NotifierProvider } from './contexts/useNotifier'
|
||||
|
||||
function RedirectHandler() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center h-full w-full bg-[#141414]">
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
useEffect(() => {
|
||||
const checkRootUser = async () => {
|
||||
const response = await fetch(`${getServerUrl()}/api/user/rootUserExists`)
|
||||
const data = await response.json()
|
||||
if (data.exists) {
|
||||
// Only navigate to gallery if we're on the root path
|
||||
if (location.pathname === '/') {
|
||||
navigate('/gallery')
|
||||
}
|
||||
} else {
|
||||
// Always redirect to onboarding if root user doesn't exist
|
||||
if (location.pathname !== '/onboarding/createRootUser') {
|
||||
navigate('/onboarding/createRootUser')
|
||||
}
|
||||
}
|
||||
}
|
||||
checkRootUser()
|
||||
}, [location.pathname, navigate])
|
||||
return (
|
||||
<NotifierProvider>
|
||||
<AccountProvider>
|
||||
<Routes>
|
||||
<Route path="/" element={<RedirectHandler />} />
|
||||
<Route path="/gallery/*" element={<Gallery />} />
|
||||
<Route path="/viewer/:albumId/:mediaId" element={<Viewer />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/onboarding/createRootUser" element={<CreateRootUser />} />
|
||||
</Routes>
|
||||
</AccountProvider>
|
||||
</NotifierProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-dom'
|
||||
import Viewer from './viewer'
|
||||
import Gallery from './gallery'
|
||||
import Login from './account/login'
|
||||
import { getServerUrl } from './hooks/getConstants'
|
||||
import { useEffect } from 'react'
|
||||
import CreateRootUser from './account/createRoot'
|
||||
import { AccountProvider } from './contexts/useAccount'
|
||||
import { NotifierProvider } from './contexts/useNotifier'
|
||||
|
||||
function RedirectHandler() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center h-full w-full bg-[#141414]">
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
useEffect(() => {
|
||||
const checkRootUser = async () => {
|
||||
const response = await fetch(`${getServerUrl()}/api/user/rootUserExists`)
|
||||
const data = await response.json()
|
||||
if (data.exists) {
|
||||
// Only navigate to gallery if we're on the root path
|
||||
if (location.pathname === '/') {
|
||||
navigate('/gallery')
|
||||
}
|
||||
} else {
|
||||
// Always redirect to onboarding if root user doesn't exist
|
||||
if (location.pathname !== '/onboarding/createRootUser') {
|
||||
navigate('/onboarding/createRootUser')
|
||||
}
|
||||
}
|
||||
}
|
||||
checkRootUser()
|
||||
}, [location.pathname, navigate])
|
||||
return (
|
||||
<NotifierProvider>
|
||||
<AccountProvider>
|
||||
<Routes>
|
||||
<Route path="/" element={<RedirectHandler />} />
|
||||
<Route path="/gallery/*" element={<Gallery />} />
|
||||
<Route path="/viewer/:albumId/:mediaId" element={<Viewer />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/onboarding/createRootUser" element={<CreateRootUser />} />
|
||||
</Routes>
|
||||
</AccountProvider>
|
||||
</NotifierProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
|
||||
Reference in New Issue
Block a user