Browse Source

Add error boundary to BrowserNotifyModal. For #2811

pull/2815/head
Gabe Kangas 2 years ago
parent
commit
170a3ecde1
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
  1. 2
      web/components/modals/AuthModal/AuthModal.tsx
  2. 13
      web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx

2
web/components/modals/AuthModal/AuthModal.tsx

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

13
web/components/modals/BrowserNotifyModal/BrowserNotifyModal.tsx

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

Loading…
Cancel
Save