mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-07 18:04:56 -04:00
Add note loading boundary (#2040)
* Remove redundant equal value Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add NoteLoadingBoundary to fetch note from API before rendering Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Improve debug message for setHandler Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add test for boundary Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use common error page for note loading errors Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix tests Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Format code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add missing snapshot Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Reformat code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
0419113d36
commit
880e542351
19 changed files with 282 additions and 166 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import type { PropsWithChildren } from 'react'
|
||||
import React, { Suspense } from 'react'
|
||||
import React, { Fragment, Suspense, useMemo } from 'react'
|
||||
import { createSetUpTaskList } from './initializers'
|
||||
import { LoadingScreen } from './loading-screen/loading-screen'
|
||||
import { Logger } from '../../utils/logger'
|
||||
|
@ -27,8 +27,20 @@ export const ApplicationLoader: React.FC<PropsWithChildren<unknown>> = ({ childr
|
|||
}
|
||||
}, [])
|
||||
|
||||
if (loading) {
|
||||
return <LoadingScreen failedTaskName={error?.message} />
|
||||
const errorBlock = useMemo(() => {
|
||||
if (error) {
|
||||
return (
|
||||
<Fragment>
|
||||
{error.message}
|
||||
<br />
|
||||
For further information look into the browser console.
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
}, [error])
|
||||
|
||||
if (loading || !!errorBlock) {
|
||||
return <LoadingScreen errorMessage={errorBlock} />
|
||||
} else {
|
||||
return <Suspense fallback={<LoadingScreen />}>{children}</Suspense>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue