From d7c64643cf50f87724b716b9a5d62e4e6d248e9b Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Fri, 24 Jul 2020 20:56:20 +1200 Subject: [PATCH] Adding error boundary around Notifications to catch issues like #565 --- src/js/components/Notifications.js | 86 +++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/src/js/components/Notifications.js b/src/js/components/Notifications.js index a48511fc..8b58fd18 100755 --- a/src/js/components/Notifications.js +++ b/src/js/components/Notifications.js @@ -13,6 +13,7 @@ import Icon from './Icon'; import Loader from './Loader'; import { indexToArray } from '../util/arrays'; import { i18n, I18n } from '../locale'; +import ErrorBoundary from './ErrorBoundary'; class Notifications extends React.Component { importConfiguration(notification_key, configuration) { @@ -38,7 +39,10 @@ class Notifications extends React.Component { } this.props.uiActions.removeNotification(notification_key, true); - this.props.uiActions.createNotification({ level: 'warning', content: i18n('modal.share_configuration.import.successful') }); + this.props.uiActions.createNotification({ + level: 'warning', + content: i18n('modal.share_configuration.import.successful'), + }); } renderNotifications() { @@ -47,7 +51,7 @@ class Notifications extends React.Component { const notifications = indexToArray(this.props.notifications); return ( - + { notifications.map((notification) => { switch (notification.type) { @@ -64,8 +68,11 @@ class Notifications extends React.Component { return (
- this.props.uiActions.removeNotification(notification.key, true)} /> - + this.props.uiActions.removeNotification(notification.key, true)} + />

@@ -74,11 +81,21 @@ class Notifications extends React.Component {

    - {notification.configuration.ui ?
  • : null} - {notification.configuration.spotify ?
  • : null} - {notification.configuration.lastfm ?
  • : null} - {notification.configuration.genius ?
  • : null} - {notification.configuration.snapcast ?
  • : null} + {notification.configuration.ui && ( +
  • + )} + {notification.configuration.spotify && ( +
  • + )} + {notification.configuration.lastfm && ( +
  • + )} + {notification.configuration.genius && ( +
  • + )} + {notification.configuration.snapcast && ( +
  • + )}

@@ -96,23 +113,54 @@ class Notifications extends React.Component { default: return (

-
- this.props.uiActions.removeNotification(notification.key, true)} /> - {notification.title ?

{notification.title}

: null} - {notification.content ?
{notification.content}
: null} - {notification.description ?
{notification.description}
: null} - {notification.links ? ( -
- {notification.links.map((link, i) => {link.text})} +
+ this.props.uiActions.removeNotification(notification.key, true)} + /> + {notification.title && ( +

+ {notification.title} +

+ )} + {notification.content && ( +
+ {notification.content}
- ) : null} + )} + {notification.description && ( +
+ {notification.description} +
+ )} + {notification.links && ( +
+ { + notification.links.map((link, i) => ( + + {link.text} + + )) + } +
+ )}
); } }) } - + ); }