Add preferences for notification badges
This commit is contained in:
@ -8,20 +8,22 @@ import { connect } from 'react-redux';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
unreadNotifications: state.getIn(['notifications', 'unread']),
|
||||
showBadge: state.getIn(['local_settings', 'notifications', 'tab_badge']),
|
||||
});
|
||||
|
||||
@connect(mapStateToProps)
|
||||
class NotificationsIcon extends React.PureComponent {
|
||||
static propTypes = {
|
||||
unreadNotifications: PropTypes.number,
|
||||
showBadge: PropTypes.bool,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { unreadNotifications } = this.props;
|
||||
const { unreadNotifications, showBadge } = this.props;
|
||||
return (
|
||||
<span className='icon-badge-wrapper'>
|
||||
<i className='fa fa-fw fa-bell' />
|
||||
{ unreadNotifications > 0 && <div className='icon-badge' />}
|
||||
{ showBadge && unreadNotifications > 0 && <div className='icon-badge' />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ const mapStateToProps = state => ({
|
||||
navbarUnder: state.getIn(['local_settings', 'navbar_under']),
|
||||
dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null,
|
||||
unreadNotifications: state.getIn(['notifications', 'unread']),
|
||||
showFaviconBadge: state.getIn(['local_settings', 'notifications', 'favicon_badge']),
|
||||
});
|
||||
|
||||
const keyMap = {
|
||||
@ -118,6 +119,7 @@ export default class UI extends React.Component {
|
||||
intl: PropTypes.object.isRequired,
|
||||
dropdownMenuIsOpen: PropTypes.bool,
|
||||
unreadNotifications: PropTypes.number,
|
||||
showFaviconBadge: PropTypes.bool,
|
||||
};
|
||||
|
||||
state = {
|
||||
@ -272,9 +274,10 @@ export default class UI extends React.Component {
|
||||
if (![this.props.location.pathname, '/'].includes(prevProps.location.pathname)) {
|
||||
this.columnsAreaNode.handleChildrenContentChange();
|
||||
}
|
||||
if (this.props.unreadNotifications != prevProps.unreadNotifications) {
|
||||
if (this.props.unreadNotifications != prevProps.unreadNotifications ||
|
||||
this.props.showFaviconBadge != prevProps.showFaviconBadge) {
|
||||
if (this.favicon) {
|
||||
this.favicon.badge(this.props.unreadNotifications);
|
||||
this.favicon.badge(this.props.showFaviconBadge ? this.props.unreadNotifications : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user