[FIX] Status text not being updated on sidebar (#3041)
* Update StatusView.js * Minor tweak * Minor tweaks Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
9ce374dc2d
commit
23a7f0f689
|
@ -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 (
|
||||
<List.Item
|
||||
|
@ -165,7 +166,7 @@ class StatusView extends React.Component {
|
|||
try {
|
||||
const result = await RocketChat.setUserStatus(item.id, statusText);
|
||||
if (result.success) {
|
||||
store.dispatch(setUser({ status: item.id }));
|
||||
setUser({ status: item.id });
|
||||
}
|
||||
} catch (e) {
|
||||
logEvent(events.SET_STATUS_FAIL);
|
||||
|
@ -202,4 +203,8 @@ const mapStateToProps = state => ({
|
|||
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));
|
||||
|
|
Loading…
Reference in New Issue