diff --git a/app/views/StatusView.js b/app/views/StatusView.js index f703b8e0a..4441169f5 100644 --- a/app/views/StatusView.js +++ b/app/views/StatusView.js @@ -16,8 +16,7 @@ import { LISTENER } from '../containers/Toast'; import { withTheme } from '../theme'; import { getUserSelector } from '../selectors/login'; import * as HeaderButton from '../containers/HeaderButton'; -import store from '../lib/createStore'; -import { setUser } from '../actions/login'; +import { setUser as setUserAction } from '../actions/login'; import SafeAreaView from '../containers/SafeAreaView'; const STATUS = [{ @@ -58,7 +57,8 @@ class StatusView extends React.Component { }), theme: PropTypes.string, navigation: PropTypes.object, - isMasterDetail: PropTypes.bool + isMasterDetail: PropTypes.bool, + setUser: PropTypes.func } constructor(props) { @@ -103,7 +103,7 @@ class StatusView extends React.Component { setCustomStatus = async() => { const { statusText } = this.state; - const { user } = this.props; + const { user, setUser } = this.props; this.setState({ loading: true }); @@ -111,6 +111,7 @@ class StatusView extends React.Component { const result = await RocketChat.setUserStatus(user.status, statusText); if (result.success) { logEvent(events.STATUS_CUSTOM); + setUser({ statusText }); EventEmitter.emit(LISTENER, { message: I18n.t('Status_saved_successfully') }); } else { logEvent(events.STATUS_CUSTOM_F); @@ -154,7 +155,7 @@ class StatusView extends React.Component { renderItem = ({ item }) => { const { statusText } = this.state; - const { user } = this.props; + const { user, setUser } = this.props; const { id, name } = item; return ( ({ isMasterDetail: state.app.isMasterDetail }); -export default connect(mapStateToProps)(withTheme(StatusView)); +const mapDispatchToProps = dispatch => ({ + setUser: user => dispatch(setUserAction(user)) +}); + +export default connect(mapStateToProps, mapDispatchToProps)(withTheme(StatusView));