mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
Make application loader only trigger once
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
dbc592e6d7
commit
7ef1b086bd
1 changed files with 6 additions and 1 deletions
|
@ -10,6 +10,7 @@ export const ApplicationLoader: React.FC = ({ children }) => {
|
||||||
const [doneTasks, setDoneTasks] = useState<number>(0)
|
const [doneTasks, setDoneTasks] = useState<number>(0)
|
||||||
const [initTasks, setInitTasks] = useState<InitTask[]>([])
|
const [initTasks, setInitTasks] = useState<InitTask[]>([])
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
|
const [applicationLoading, setApplicationLoading] = useState<boolean>(false)
|
||||||
|
|
||||||
const runTask = async (task: Promise<void>): Promise<void> => {
|
const runTask = async (task: Promise<void>): Promise<void> => {
|
||||||
await task
|
await task
|
||||||
|
@ -19,10 +20,14 @@ export const ApplicationLoader: React.FC = ({ children }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (applicationLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setApplicationLoading(true)
|
||||||
const baseUrl:string = window.location.pathname.replace(pathname, '') + '/'
|
const baseUrl:string = window.location.pathname.replace(pathname, '') + '/'
|
||||||
console.debug('Base URL is', baseUrl)
|
console.debug('Base URL is', baseUrl)
|
||||||
setInitTasks(setUp(baseUrl))
|
setInitTasks(setUp(baseUrl))
|
||||||
}, [pathname])
|
}, [applicationLoading, pathname])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
for (const task of initTasks) {
|
for (const task of initTasks) {
|
||||||
|
|
Loading…
Reference in a new issue