summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-06-26 13:25:43 -0400
committerGitHub <noreply@github.com>2017-06-26 13:25:43 -0400
commit82b36b3721d6ee129d27c3fc3957d4e37643d4a6 (patch)
treee43d5cdb6e008149196781b4cd9146ce14447ac5 /webapp
parent072da672a8bd62d730977a73966274b47ea9e0de (diff)
downloadchat-82b36b3721d6ee129d27c3fc3957d4e37643d4a6.tar.gz
chat-82b36b3721d6ee129d27c3fc3957d4e37643d4a6.tar.bz2
chat-82b36b3721d6ee129d27c3fc3957d4e37643d4a6.zip
PLT-6815 Do not disconnect websocket when joining a team (#6746)
* Do not disconnect websocket when joining a team * Fix eslint error
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/team_actions.jsx41
-rw-r--r--webapp/components/select_team/components/select_team_item.jsx27
-rw-r--r--webapp/components/select_team/select_team.jsx1
3 files changed, 29 insertions, 40 deletions
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx
index a0d208301..af132b139 100644
--- a/webapp/actions/team_actions.jsx
+++ b/webapp/actions/team_actions.jsx
@@ -18,7 +18,6 @@ import {viewChannel} from 'mattermost-redux/actions/channels';
import * as TeamActions from 'mattermost-redux/actions/teams';
import {TeamTypes} from 'mattermost-redux/action_types';
-import {batchActions} from 'redux-batched-actions';
export function checkIfTeamExists(teamName, onSuccess, onError) {
TeamActions.checkIfTeamExists(teamName)(dispatch, getState).then(
@@ -92,30 +91,24 @@ export function updateTeamMemberRoles(teamId, userId, newRoles, success, error)
export function addUserToTeamFromInvite(data, hash, inviteId, success, error) {
Client4.addToTeamFromInvite(hash, data, inviteId).then(
- (team) => {
- const member = {
- team_id: team.id,
- user_id: getState().entities.users.currentUserId,
- roles: 'team_user',
- delete_at: 0,
- msg_count: 0,
- mention_count: 0
- };
-
- dispatch(batchActions([
- {
- type: TeamTypes.RECEIVED_TEAMS_LIST,
- data: [team]
- },
- {
- type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
- data: member
+ (member) => {
+ TeamActions.getTeam(member.team_id)(dispatch, getState).then(
+ (team) => {
+ dispatch({
+ type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
+ data: {
+ ...member,
+ delete_at: 0,
+ msg_count: 0,
+ mention_count: 0
+ }
+ });
+
+ if (success) {
+ success(team);
+ }
}
- ]));
-
- if (success) {
- success(team);
- }
+ );
},
).catch(
(err) => {
diff --git a/webapp/components/select_team/components/select_team_item.jsx b/webapp/components/select_team/components/select_team_item.jsx
index 201c9c8ab..0d47ba7e1 100644
--- a/webapp/components/select_team/components/select_team_item.jsx
+++ b/webapp/components/select_team/components/select_team_item.jsx
@@ -1,30 +1,28 @@
-import PropTypes from 'prop-types';
-
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import React from 'react';
+import * as Utils from 'utils/utils.jsx';
+import {addUserToTeamFromInvite} from 'actions/team_actions.jsx';
-import {Link} from 'react-router/es6';
+import React from 'react';
+import PropTypes from 'prop-types';
+import {Link, browserHistory} from 'react-router/es6';
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
import {Constants} from 'utils/constants.jsx';
-import * as Utils from 'utils/utils.jsx';
-export default class SelectTeamItem extends React.Component {
+export default class SelectTeamItem extends React.PureComponent {
static propTypes = {
team: PropTypes.object.isRequired,
- url: PropTypes.string.isRequired,
onTeamClick: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired
};
- constructor(props) {
- super(props);
-
- this.handleTeamClick = this.handleTeamClick.bind(this);
- }
-
- handleTeamClick() {
+ handleTeamClick = () => {
+ addUserToTeamFromInvite('', '', this.props.team.invite_id,
+ () => {
+ browserHistory.push(`/${this.props.team.name}/channels/town-square`);
+ }
+ );
this.props.onTeamClick(this.props.team);
}
@@ -71,7 +69,6 @@ export default class SelectTeamItem extends React.Component {
{showDescriptionTooltip}
<Link
id={Utils.createSafeId(this.props.team.display_name)}
- to={this.props.url}
onClick={this.handleTeamClick}
>
<span className='signup-team-dir__name'>{this.props.team.display_name}</span>
diff --git a/webapp/components/select_team/select_team.jsx b/webapp/components/select_team/select_team.jsx
index fe706af0f..7c90160bb 100644
--- a/webapp/components/select_team/select_team.jsx
+++ b/webapp/components/select_team/select_team.jsx
@@ -84,7 +84,6 @@ export default class SelectTeam extends React.Component {
<SelectTeamItem
key={'team_' + openTeam.name}
team={openTeam}
- url={`/signup_user_complete/?id=${openTeam.invite_id}`}
onTeamClick={this.handleTeamClick}
loading={this.state.loadingTeamId === openTeam.id}
/>