RN-204 Added error alert when failing to join a team (#678)
This commit is contained in:
parent
a8b49ef3a4
commit
77c701b03a
2 changed files with 17 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ function mapStateToProps(state, ownProps) {
|
|||
teamsRequest: state.requests.teams.getMyTeams,
|
||||
teams: Object.values(getJoinableTeams(state)).sort(sortTeams),
|
||||
currentChannelId: getCurrentChannelId(state),
|
||||
joinTeamRequest: state.requests.teams.joinTeam,
|
||||
...ownProps
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import React, {PureComponent} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Alert,
|
||||
FlatList,
|
||||
InteractionManager,
|
||||
StyleSheet,
|
||||
|
|
@ -12,11 +13,13 @@ import {
|
|||
View
|
||||
} from 'react-native';
|
||||
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
import Loading from 'app/components/loading';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
|
|
@ -31,6 +34,7 @@ export default class SelectTeam extends PureComponent {
|
|||
}).isRequired,
|
||||
currentChannelId: PropTypes.string,
|
||||
currentUrl: PropTypes.string.isRequired,
|
||||
joinTeamRequest: PropTypes.object.isRequired,
|
||||
navigator: PropTypes.object,
|
||||
userWithoutTeams: PropTypes.bool,
|
||||
teams: PropTypes.array.isRequired,
|
||||
|
|
@ -55,6 +59,11 @@ export default class SelectTeam extends PureComponent {
|
|||
if (this.props.teams !== nextProps.teams) {
|
||||
this.buildData(nextProps);
|
||||
}
|
||||
|
||||
if (this.props.joinTeamRequest.status !== RequestStatus.FAILURE &&
|
||||
nextProps.joinTeamRequest.status === RequestStatus.FAILURE) {
|
||||
Alert.alert('', nextProps.joinTeamRequest.error.message);
|
||||
}
|
||||
}
|
||||
|
||||
buildData = (props) => {
|
||||
|
|
@ -118,7 +127,13 @@ export default class SelectTeam extends PureComponent {
|
|||
if (currentChannelId) {
|
||||
markChannelAsRead(currentChannelId);
|
||||
}
|
||||
await joinTeam(team.invite_id, team.id);
|
||||
|
||||
const success = await joinTeam(team.invite_id, team.id);
|
||||
if (!success) {
|
||||
this.setState({joining: false});
|
||||
return;
|
||||
}
|
||||
|
||||
handleTeamChange(team);
|
||||
|
||||
if (userWithoutTeams) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue