[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 { withTheme } from '../theme';
|
||||||
import { getUserSelector } from '../selectors/login';
|
import { getUserSelector } from '../selectors/login';
|
||||||
import * as HeaderButton from '../containers/HeaderButton';
|
import * as HeaderButton from '../containers/HeaderButton';
|
||||||
import store from '../lib/createStore';
|
import { setUser as setUserAction } from '../actions/login';
|
||||||
import { setUser } from '../actions/login';
|
|
||||||
import SafeAreaView from '../containers/SafeAreaView';
|
import SafeAreaView from '../containers/SafeAreaView';
|
||||||
|
|
||||||
const STATUS = [{
|
const STATUS = [{
|
||||||
|
@ -58,7 +57,8 @@ class StatusView extends React.Component {
|
||||||
}),
|
}),
|
||||||
theme: PropTypes.string,
|
theme: PropTypes.string,
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
isMasterDetail: PropTypes.bool
|
isMasterDetail: PropTypes.bool,
|
||||||
|
setUser: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -103,7 +103,7 @@ class StatusView extends React.Component {
|
||||||
|
|
||||||
setCustomStatus = async() => {
|
setCustomStatus = async() => {
|
||||||
const { statusText } = this.state;
|
const { statusText } = this.state;
|
||||||
const { user } = this.props;
|
const { user, setUser } = this.props;
|
||||||
|
|
||||||
this.setState({ loading: true });
|
this.setState({ loading: true });
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ class StatusView extends React.Component {
|
||||||
const result = await RocketChat.setUserStatus(user.status, statusText);
|
const result = await RocketChat.setUserStatus(user.status, statusText);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
logEvent(events.STATUS_CUSTOM);
|
logEvent(events.STATUS_CUSTOM);
|
||||||
|
setUser({ statusText });
|
||||||
EventEmitter.emit(LISTENER, { message: I18n.t('Status_saved_successfully') });
|
EventEmitter.emit(LISTENER, { message: I18n.t('Status_saved_successfully') });
|
||||||
} else {
|
} else {
|
||||||
logEvent(events.STATUS_CUSTOM_F);
|
logEvent(events.STATUS_CUSTOM_F);
|
||||||
|
@ -154,7 +155,7 @@ class StatusView extends React.Component {
|
||||||
|
|
||||||
renderItem = ({ item }) => {
|
renderItem = ({ item }) => {
|
||||||
const { statusText } = this.state;
|
const { statusText } = this.state;
|
||||||
const { user } = this.props;
|
const { user, setUser } = this.props;
|
||||||
const { id, name } = item;
|
const { id, name } = item;
|
||||||
return (
|
return (
|
||||||
<List.Item
|
<List.Item
|
||||||
|
@ -165,7 +166,7 @@ class StatusView extends React.Component {
|
||||||
try {
|
try {
|
||||||
const result = await RocketChat.setUserStatus(item.id, statusText);
|
const result = await RocketChat.setUserStatus(item.id, statusText);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
store.dispatch(setUser({ status: item.id }));
|
setUser({ status: item.id });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logEvent(events.SET_STATUS_FAIL);
|
logEvent(events.SET_STATUS_FAIL);
|
||||||
|
@ -202,4 +203,8 @@ const mapStateToProps = state => ({
|
||||||
isMasterDetail: state.app.isMasterDetail
|
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