0

Add error boundary to ChatModerationDetailsModal. For #2811

This commit is contained in:
Gabe Kangas 2023-03-12 23:10:20 -07:00
parent 9162386495
commit 7cb5773a97
No known key found for this signature in database
GPG Key ID: 4345B2060657F330

View File

@ -3,9 +3,11 @@ import { FC, useEffect, useState } from 'react';
import format from 'date-fns/format'; import format from 'date-fns/format';
import { ColumnsType } from 'antd/lib/table'; import { ColumnsType } from 'antd/lib/table';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { ErrorBoundary } from 'react-error-boundary';
import ChatModeration from '../../../services/moderation-service'; import ChatModeration from '../../../services/moderation-service';
import styles from './ChatModerationDetailsModal.module.scss'; import styles from './ChatModerationDetailsModal.module.scss';
import { formatUAstring } from '../../../utils/format'; import { formatUAstring } from '../../../utils/format';
import { ComponentError } from '../../ui/ComponentError/ComponentError';
const { Panel } = Collapse; const { Panel } = Collapse;
@ -148,6 +150,16 @@ export const ChatModerationDetailsModal: FC<ChatModerationDetailsModalProps> = (
}, },
]; ];
return ( return (
<ErrorBoundary
// eslint-disable-next-line react/no-unstable-nested-components
fallbackRender={({ error, resetErrorBoundary }) => (
<ComponentError
componentName="ChatModerationDetailsModal"
message={error.message}
retryFunction={resetErrorBoundary}
/>
)}
>
<Spin spinning={loading}> <Spin spinning={loading}>
<UserColorBlock color={displayColor} /> <UserColorBlock color={displayColor} />
{scopes?.map(scope => ( {scopes?.map(scope => (
@ -181,5 +193,6 @@ export const ChatModerationDetailsModal: FC<ChatModerationDetailsModalProps> = (
</Collapse> </Collapse>
</Collapse> </Collapse>
</Spin> </Spin>
</ErrorBoundary>
); );
}; };