You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
809 B

  1. import { PureComponent } from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import { title } from 'mastodon/initial_state';
  5. const mapStateToProps = state => ({
  6. unread: state.getIn(['missed_updates', 'unread']),
  7. });
  8. export default @connect(mapStateToProps)
  9. class DocumentTitle extends PureComponent {
  10. static propTypes = {
  11. unread: PropTypes.number.isRequired,
  12. };
  13. componentDidMount () {
  14. this._sideEffects();
  15. }
  16. componentDidUpdate() {
  17. this._sideEffects();
  18. }
  19. _sideEffects () {
  20. const { unread } = this.props;
  21. if (unread > 99) {
  22. document.title = `(*) ${title}`;
  23. } else if (unread > 0) {
  24. document.title = `(${unread}) ${title}`;
  25. } else {
  26. document.title = title;
  27. }
  28. }
  29. render () {
  30. return null;
  31. }
  32. }