fix(document.title): Update document title for Challenge route
This commit is contained in:
		@@ -15,8 +15,8 @@ import Modern from './views/Modern';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  fetchChallenge,
 | 
					  fetchChallenge,
 | 
				
			||||||
 | 
					  challengeSelector,
 | 
				
			||||||
  challengeSelector
 | 
					  updateTitle
 | 
				
			||||||
} from '../../redux';
 | 
					} from '../../redux';
 | 
				
			||||||
import { makeToast } from '../../Toasts/redux';
 | 
					import { makeToast } from '../../Toasts/redux';
 | 
				
			||||||
import { paramsSelector } from '../../Router/redux';
 | 
					import { paramsSelector } from '../../Router/redux';
 | 
				
			||||||
@@ -33,7 +33,8 @@ const views = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const mapDispatchToProps = {
 | 
					const mapDispatchToProps = {
 | 
				
			||||||
  fetchChallenge,
 | 
					  fetchChallenge,
 | 
				
			||||||
  makeToast
 | 
					  makeToast,
 | 
				
			||||||
 | 
					  updateTitle
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const mapStateToProps = createSelector(
 | 
					const mapStateToProps = createSelector(
 | 
				
			||||||
@@ -42,12 +43,13 @@ const mapStateToProps = createSelector(
 | 
				
			|||||||
  paramsSelector,
 | 
					  paramsSelector,
 | 
				
			||||||
  (
 | 
					  (
 | 
				
			||||||
    { dashedName, isTranslated },
 | 
					    { dashedName, isTranslated },
 | 
				
			||||||
    { viewType },
 | 
					    { viewType, title },
 | 
				
			||||||
    params,
 | 
					    params
 | 
				
			||||||
  ) => ({
 | 
					  ) => ({
 | 
				
			||||||
    challenge: dashedName,
 | 
					    challenge: dashedName,
 | 
				
			||||||
    isTranslated,
 | 
					    isTranslated,
 | 
				
			||||||
    params,
 | 
					    params,
 | 
				
			||||||
 | 
					    title,
 | 
				
			||||||
    viewType
 | 
					    viewType
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
@@ -64,6 +66,8 @@ const propTypes = {
 | 
				
			|||||||
    dashedName: PropTypes.string,
 | 
					    dashedName: PropTypes.string,
 | 
				
			||||||
    lang: PropTypes.string.isRequired
 | 
					    lang: PropTypes.string.isRequired
 | 
				
			||||||
  }),
 | 
					  }),
 | 
				
			||||||
 | 
					  title: PropTypes.string,
 | 
				
			||||||
 | 
					  updateTitle: PropTypes.func.isRequired,
 | 
				
			||||||
  viewType: PropTypes.string
 | 
					  viewType: PropTypes.string
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -82,12 +86,16 @@ export class Show extends PureComponent {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  componentDidMount() {
 | 
					  componentDidMount() {
 | 
				
			||||||
 | 
					    this.props.updateTitle(this.props.title);
 | 
				
			||||||
    if (this.isNotTranslated(this.props)) {
 | 
					    if (this.isNotTranslated(this.props)) {
 | 
				
			||||||
      this.makeTranslateToast();
 | 
					      this.makeTranslateToast();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  componentWillReceiveProps(nextProps) {
 | 
					  componentWillReceiveProps(nextProps) {
 | 
				
			||||||
 | 
					    if (this.props.title !== nextProps.title) {
 | 
				
			||||||
 | 
					      this.props.updateTitle(nextProps.title);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    const { params: { dashedName } } = nextProps;
 | 
					    const { params: { dashedName } } = nextProps;
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
      this.props.params.dashedName !== dashedName &&
 | 
					      this.props.params.dashedName !== dashedName &&
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user