Add error boundary to BrowserNotifyModal. For #2811

This commit is contained in:
Gabe Kangas 2023-03-12 23:05:21 -07:00
parent 02e937c351
commit 170a3ecde1
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
2 changed files with 23 additions and 10 deletions

View File

@ -72,7 +72,7 @@ export const AuthModal: FC<AuthModalProps> = ({ forceTabs }) => {
// eslint-disable-next-line react/no-unstable-nested-components
fallbackRender={({ error, resetErrorBoundary }) => (
<ComponentError
componentName="ChatContainer"
componentName="AuthModal"
message={error.message}
retryFunction={resetErrorBoundary}
/>

View File

@ -1,6 +1,7 @@
import { Row, Spin, Typography, Button } from 'antd';
import React, { FC, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { ErrorBoundary } from 'react-error-boundary';
import { accessTokenAtom, clientConfigStateAtom } from '../../stores/ClientConfigStore';
import {
registerWebPushNotifications,
@ -8,6 +9,7 @@ import {
} from '../../../services/notifications-service';
import styles from './BrowserNotifyModal.module.scss';
import isPushNotificationSupported from '../../../utils/browserPushNotifications';
import { ComponentError } from '../../ui/ComponentError/ComponentError';
const { Title } = Typography;
@ -109,14 +111,25 @@ export const BrowserNotifyModal = () => {
}
return (
<Spin spinning={browserPushPermissionsPending}>
<Row className={styles.description}>
Get notified right in the browser each time this stream goes live.
<a href="https://owncast.online/docs/notifications/#browser-notifications">Learn more</a>
&nbsp; about Owncast browser notifications.
</Row>
<Row>{error}</Row>
<PermissionPopupPreview start={() => startBrowserPushRegistration()} />
</Spin>
<ErrorBoundary
// eslint-disable-next-line react/no-unstable-nested-components
fallbackRender={({ error, resetErrorBoundary }) => (
<ComponentError
componentName="BrowserNotifyModal"
message={error.message}
retryFunction={resetErrorBoundary}
/>
)}
>
<Spin spinning={browserPushPermissionsPending}>
<Row className={styles.description}>
Get notified right in the browser each time this stream goes live.
<a href="https://owncast.online/docs/notifications/#browser-notifications">Learn more</a>
&nbsp; about Owncast browser notifications.
</Row>
<Row>{error}</Row>
<PermissionPopupPreview start={() => startBrowserPushRegistration()} />
</Spin>
</ErrorBoundary>
);
};