Add notifications counter to tab title, fixes #21
This commit is contained in:
parent
05db2fc35f
commit
082b429fee
1 changed files with 10 additions and 2 deletions
|
@ -5,6 +5,7 @@ import { Helmet } from'react-helmet';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
siteTitle: state.getIn(['instance', 'title']),
|
siteTitle: state.getIn(['instance', 'title']),
|
||||||
|
unreadCount: state.getIn(['notifications', 'unread']),
|
||||||
});
|
});
|
||||||
|
|
||||||
class SoapboxHelmet extends React.Component {
|
class SoapboxHelmet extends React.Component {
|
||||||
|
@ -12,15 +13,22 @@ class SoapboxHelmet extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
siteTitle: PropTypes.string,
|
siteTitle: PropTypes.string,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
|
unreadCount: PropTypes.number,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
addCounter = title => {
|
||||||
|
const { unreadCount } = this.props;
|
||||||
|
if (unreadCount < 1) return title;
|
||||||
|
return `(${unreadCount}) ${title}`;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { siteTitle, children } = this.props;
|
const { siteTitle, children } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Helmet
|
<Helmet
|
||||||
titleTemplate={`%s | ${siteTitle}`}
|
titleTemplate={this.addCounter(`%s | ${siteTitle}`)}
|
||||||
defaultTitle={siteTitle}
|
defaultTitle={this.addCounter(siteTitle)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Helmet>
|
</Helmet>
|
||||||
|
|
Loading…
Reference in a new issue