1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Guard against the notification dropdown button missing a function

This commit is contained in:
Brett Sun 2016-02-05 10:39:24 +01:00
parent 826ca08073
commit 8927ccb847

View File

@ -11,16 +11,12 @@ import Nav from 'react-bootstrap/lib/Nav';
import NotificationActions from '../actions/notification_actions'; import NotificationActions from '../actions/notification_actions';
import NotificationStore from '../stores/notification_store'; import NotificationStore from '../stores/notification_store';
import { mergeOptions } from '../utils/general_utils';
import { getLangText } from '../utils/lang_utils'; import { getLangText } from '../utils/lang_utils';
let HeaderNotifications = React.createClass({ let HeaderNotifications = React.createClass({
getInitialState() { getInitialState() {
return mergeOptions( return NotificationStore.getState();
NotificationStore.getState()
);
}, },
componentDidMount() { componentDidMount() {
@ -59,10 +55,14 @@ let HeaderNotifications = React.createClass({
NOW, THAT DIDN'T WORK - the onSelect routine isnt triggered in all cases NOW, THAT DIDN'T WORK - the onSelect routine isnt triggered in all cases
Hence, we do this manually 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) { if (this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) {
return ( return (
<div> <div>
@ -87,7 +87,7 @@ let HeaderNotifications = React.createClass({
return null; return null;
}, },
getEditionNotifications(){ getEditionNotifications() {
if (this.state.editionListNotifications && this.state.editionListNotifications.length > 0) { if (this.state.editionListNotifications && this.state.editionListNotifications.length > 0) {
return ( return (
<div> <div>
@ -114,7 +114,7 @@ let HeaderNotifications = React.createClass({
render() { render() {
if ((this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) || 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; let numNotifications = 0;
if (this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) { if (this.state.pieceListNotifications && this.state.pieceListNotifications.length > 0) {
numNotifications += this.state.pieceListNotifications.length; numNotifications += this.state.pieceListNotifications.length;
@ -125,7 +125,7 @@ let HeaderNotifications = React.createClass({
return ( return (
<Nav navbar right> <Nav navbar right>
<DropdownButton <DropdownButton
ref='dropdownbutton' ref='dropdownButton'
id="header-notification-dropdown" id="header-notification-dropdown"
eventKey="1" eventKey="1"
title={ title={