mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Make notification fetching dependent on if the current user is available
This commit is contained in:
parent
114129588e
commit
30911b5395
@ -218,7 +218,7 @@ let Header = React.createClass({
|
|||||||
{account}
|
{account}
|
||||||
{signup}
|
{signup}
|
||||||
</Nav>
|
</Nav>
|
||||||
<HeaderNotifications />
|
<HeaderNotifications currentUser={currentUser} />
|
||||||
{navRoutesLinks}
|
{navRoutesLinks}
|
||||||
</CollapsibleNav>
|
</CollapsibleNav>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
@ -15,14 +15,26 @@ import { getLangText } from '../utils/lang_utils';
|
|||||||
|
|
||||||
|
|
||||||
let HeaderNotifications = React.createClass({
|
let HeaderNotifications = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
currentUser: React.PropTypes.object.isRequired
|
||||||
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return NotificationStore.getState();
|
return NotificationStore.getState();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
NotificationStore.listen(this.onChange);
|
NotificationStore.listen(this.onChange);
|
||||||
NotificationActions.fetchPieceListNotifications();
|
|
||||||
NotificationActions.fetchEditionListNotifications();
|
if (this.props.currentUser.email) {
|
||||||
|
this.refreshNotifications();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if (nextProps.currentUser && nextProps.currentUser.email !== this.props.currentUser.email) {
|
||||||
|
this.refreshNotifications();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -58,7 +70,12 @@ let HeaderNotifications = React.createClass({
|
|||||||
this.refs.dropdownbutton.setDropdownState(false);
|
this.refs.dropdownbutton.setDropdownState(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
getNotifications({ notifications, isPiece }) {
|
refreshNotifications() {
|
||||||
|
NotificationActions.fetchPieceListNotifications();
|
||||||
|
NotificationActions.fetchEditionListNotifications();
|
||||||
|
},
|
||||||
|
|
||||||
|
renderNotifications({ notifications, isPiece }) {
|
||||||
if (notifications.length) {
|
if (notifications.length) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -107,8 +124,8 @@ let HeaderNotifications = React.createClass({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
className="notification-menu">
|
className="notification-menu">
|
||||||
{this.getNotifications({ notifications: pieceListNotifications, isPiece: true })}
|
{this.renderNotifications({ notifications: pieceListNotifications, isPiece: true })}
|
||||||
{this.getNotifications({ notifications: editionListNotifications, isPiece: false })}
|
{this.renderNotifications({ notifications: editionListNotifications, isPiece: false })}
|
||||||
</DropdownButton>
|
</DropdownButton>
|
||||||
</Nav>
|
</Nav>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user