From 8927ccb847ec8569971d154bd2fa4c8cb54962a6 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 5 Feb 2016 10:39:24 +0100 Subject: [PATCH] Guard against the notification dropdown button missing a function --- js/components/header_notification.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/js/components/header_notification.js b/js/components/header_notification.js index 784f8786..84b71177 100644 --- a/js/components/header_notification.js +++ b/js/components/header_notification.js @@ -11,16 +11,12 @@ import Nav from 'react-bootstrap/lib/Nav'; import NotificationActions from '../actions/notification_actions'; import NotificationStore from '../stores/notification_store'; -import { mergeOptions } from '../utils/general_utils'; import { getLangText } from '../utils/lang_utils'; let HeaderNotifications = React.createClass({ - getInitialState() { - return mergeOptions( - NotificationStore.getState() - ); + return NotificationStore.getState(); }, componentDidMount() { @@ -59,10 +55,14 @@ let HeaderNotifications = React.createClass({ NOW, THAT DIDN'T WORK - the onSelect routine isnt triggered in all cases Hence, we do this manually */ - this.refs.dropdownbutton.setDropdownState(false); + const { dropdownButton } = this.refs; + + if (dropdownButton && typeof dropdownButton.setDropdownState === 'function') { + dropdownbutton.setDropdownState(false); + } }, - getPieceNotifications(){ + getPieceNotifications() { if (this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) { return (
@@ -87,7 +87,7 @@ let HeaderNotifications = React.createClass({ return null; }, - getEditionNotifications(){ + getEditionNotifications() { if (this.state.editionListNotifications && this.state.editionListNotifications.length > 0) { return (
@@ -114,7 +114,7 @@ let HeaderNotifications = React.createClass({ render() { if ((this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) || - (this.state.editionListNotifications && this.state.editionListNotifications.length > 0)){ + (this.state.editionListNotifications && this.state.editionListNotifications.length > 0)) { let numNotifications = 0; if (this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) { numNotifications += this.state.pieceListNotifications.length; @@ -125,7 +125,7 @@ let HeaderNotifications = React.createClass({ return (