mirror of
https://github.com/owncast/owncast.git
synced 2024-11-29 11:39:08 +03:00
Add error boundary to chat. For #2811
This commit is contained in:
parent
593a7faa36
commit
4192482a4c
1 changed files with 20 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Virtuoso } from 'react-virtuoso';
|
||||
import { useState, useMemo, useRef, CSSProperties, FC, useEffect } from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import {
|
||||
ConnectedClientInfoEvent,
|
||||
FediverseEvent,
|
||||
|
@ -18,6 +19,7 @@ import { ChatActionMessage } from '../ChatActionMessage/ChatActionMessage';
|
|||
import { ChatSocialMessage } from '../ChatSocialMessage/ChatSocialMessage';
|
||||
import { ChatNameChangeMessage } from '../ChatNameChangeMessage/ChatNameChangeMessage';
|
||||
import { User } from '../../../interfaces/user.model';
|
||||
import { ComponentError } from '../../ui/ComponentError/ComponentError';
|
||||
|
||||
export type ChatContainerProps = {
|
||||
messages: ChatMessage[];
|
||||
|
@ -266,6 +268,16 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
);
|
||||
|
||||
return (
|
||||
<ErrorBoundary
|
||||
// eslint-disable-next-line react/no-unstable-nested-components
|
||||
fallbackRender={({ error, resetErrorBoundary }) => (
|
||||
<ComponentError
|
||||
componentName="ChatContainer"
|
||||
message={error.message}
|
||||
retryFunction={resetErrorBoundary}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<div id="chat-container" className={styles.chatContainer}>
|
||||
{MessagesTable}
|
||||
{showInput && (
|
||||
|
@ -274,6 +286,7 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue