|
|
@@ -42,7 +42,6 @@ export const RevisionLoader = (props: RevisionLoaderProps): JSX.Element => {
|
|
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
|
const [isLoaded, setIsLoaded] = useState<boolean>(false);
|
|
|
const [markdown, setMarkdown] = useState<string>('');
|
|
|
- const [errors, setErrors] = useState<any | null>(null);
|
|
|
|
|
|
const loadData = useCallback(async() => {
|
|
|
if (!isLoaded && !isLoading) {
|
|
|
@@ -60,14 +59,23 @@ export const RevisionLoader = (props: RevisionLoaderProps): JSX.Element => {
|
|
|
}
|
|
|
}
|
|
|
catch (errors) {
|
|
|
- setErrors(errors);
|
|
|
+ const isForbidden = errors != null && errors[0].code === 'forbidden-page';
|
|
|
+ if (isForbidden) {
|
|
|
+ setMarkdown(`<i class="icon-exclamation p-1"></i>${t('not_allowed_to_see_this_page')}`);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ const errorMessages = errors.map((error) => {
|
|
|
+ return `<i class="icon-exclamation p-1"></i><span class="text-muted"><em>${error.message}</em></span>`;
|
|
|
+ });
|
|
|
+ setMarkdown(errorMessages.join('\n'));
|
|
|
+ }
|
|
|
}
|
|
|
finally {
|
|
|
setIsLoaded(true);
|
|
|
setIsLoading(false);
|
|
|
}
|
|
|
|
|
|
- }, [isLoaded, isLoading, mutatePageRevision, onRevisionLoaded]);
|
|
|
+ }, [isLoaded, isLoading, mutatePageRevision, onRevisionLoaded, t]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (!lazy) {
|
|
|
@@ -82,21 +90,6 @@ export const RevisionLoader = (props: RevisionLoaderProps): JSX.Element => {
|
|
|
return;
|
|
|
};
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- if (errors == null) return;
|
|
|
-
|
|
|
- const isForbidden = errors != null && errors[0].code === 'forbidden-page';
|
|
|
- if (isForbidden) {
|
|
|
- setMarkdown(`<i class="icon-exclamation p-1"></i>${t('not_allowed_to_see_this_page')}`);
|
|
|
- }
|
|
|
- else {
|
|
|
- const errorMessages = errors.map((error) => {
|
|
|
- return `<i class="icon-exclamation p-1"></i><span class="text-muted"><em>${error.message}</em></span>`;
|
|
|
- });
|
|
|
- setMarkdown(errorMessages.join('\n'));
|
|
|
- }
|
|
|
- }, [errors, t]);
|
|
|
-
|
|
|
/* ----- before load ----- */
|
|
|
if (lazy && !isLoaded) {
|
|
|
return (
|