feat(challenges): Call updateSuccessMessage action (#16742)
Called updateSuccessMessage passing it a random compliment each time the challenge is mounted/updated Closes #16738
This commit is contained in:
committed by
Stuart Taylor
parent
1a5cab57a1
commit
6276321f45
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
import { challengeMetaSelector } from './redux';
|
import { challengeMetaSelector, updateSuccessMessage } from './redux';
|
||||||
|
|
||||||
import Classic from './views/classic';
|
import Classic from './views/classic';
|
||||||
import Step from './views/step';
|
import Step from './views/step';
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
import { makeToast } from '../../Toasts/redux';
|
import { makeToast } from '../../Toasts/redux';
|
||||||
import { paramsSelector } from '../../Router/redux';
|
import { paramsSelector } from '../../Router/redux';
|
||||||
|
import { randomCompliment } from '../../utils/get-words';
|
||||||
|
|
||||||
const views = {
|
const views = {
|
||||||
backend: BackEnd,
|
backend: BackEnd,
|
||||||
@@ -33,7 +34,8 @@ const views = {
|
|||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
fetchChallenge,
|
fetchChallenge,
|
||||||
makeToast,
|
makeToast,
|
||||||
updateTitle
|
updateTitle,
|
||||||
|
updateSuccessMessage
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
@@ -66,6 +68,7 @@ const propTypes = {
|
|||||||
lang: PropTypes.string.isRequired
|
lang: PropTypes.string.isRequired
|
||||||
}),
|
}),
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
updateSuccessMessage: PropTypes.func.isRequired,
|
||||||
updateTitle: PropTypes.func.isRequired,
|
updateTitle: PropTypes.func.isRequired,
|
||||||
viewType: PropTypes.string
|
viewType: PropTypes.string
|
||||||
};
|
};
|
||||||
@@ -86,6 +89,7 @@ export class Show extends PureComponent {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.updateTitle(this.props.title);
|
this.props.updateTitle(this.props.title);
|
||||||
|
this.props.updateSuccessMessage(randomCompliment());
|
||||||
if (this.isNotTranslated(this.props)) {
|
if (this.isNotTranslated(this.props)) {
|
||||||
this.makeTranslateToast();
|
this.makeTranslateToast();
|
||||||
}
|
}
|
||||||
@@ -96,11 +100,11 @@ export class Show extends PureComponent {
|
|||||||
this.props.updateTitle(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 &&
|
this.props.updateSuccessMessage(randomCompliment());
|
||||||
this.isNotTranslated(nextProps)
|
if (this.isNotTranslated(nextProps)) {
|
||||||
) {
|
this.makeTranslateToast();
|
||||||
this.makeTranslateToast();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user