Fixing websocket and team store issues when leaving team (#4412)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
60a43a5b4f
Коммит
b0f38f8a84
10
api/team.go
10
api/team.go
@@ -347,6 +347,12 @@ func LeaveTeam(team *model.Team, user *model.User) *model.AppError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the websocket message before we actually do the remove so the user being removed gets it.
|
||||||
|
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_LEAVE_TEAM, team.Id, "", "", nil)
|
||||||
|
message.Add("user_id", user.Id)
|
||||||
|
message.Add("team_id", team.Id)
|
||||||
|
Publish(message)
|
||||||
|
|
||||||
teamMember.Roles = ""
|
teamMember.Roles = ""
|
||||||
teamMember.DeleteAt = model.GetMillis()
|
teamMember.DeleteAt = model.GetMillis()
|
||||||
|
|
||||||
@@ -361,10 +367,6 @@ func LeaveTeam(team *model.Team, user *model.User) *model.AppError {
|
|||||||
RemoveAllSessionsForUserId(user.Id)
|
RemoveAllSessionsForUserId(user.Id)
|
||||||
InvalidateCacheForUser(user.Id)
|
InvalidateCacheForUser(user.Id)
|
||||||
|
|
||||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_LEAVE_TEAM, team.Id, "", "", nil)
|
|
||||||
message.Add("user_id", user.Id)
|
|
||||||
go Publish(message)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,10 +211,10 @@ function handleNewUserEvent(msg) {
|
|||||||
|
|
||||||
function handleLeaveTeamEvent(msg) {
|
function handleLeaveTeamEvent(msg) {
|
||||||
if (UserStore.getCurrentId() === msg.data.user_id) {
|
if (UserStore.getCurrentId() === msg.data.user_id) {
|
||||||
TeamStore.removeMyTeamMember(msg.broadcast.team_id);
|
TeamStore.removeMyTeamMember(msg.data.team_id);
|
||||||
|
|
||||||
// if they are on the team being removed redirect them to the root
|
// if they are on the team being removed redirect them to the root
|
||||||
if (TeamStore.getCurrentId() === msg.broadcast.team_id) {
|
if (TeamStore.getCurrentId() === msg.data.team_id) {
|
||||||
TeamStore.setCurrentId('');
|
TeamStore.setCurrentId('');
|
||||||
Client.setTeamId('');
|
Client.setTeamId('');
|
||||||
browserHistory.push('/');
|
browserHistory.push('/');
|
||||||
|
|||||||
@@ -176,11 +176,9 @@ class TeamStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeMyTeamMember(teamId) {
|
removeMyTeamMember(teamId) {
|
||||||
for (var index in this.my_team_members) {
|
for (let i = 0; i < this.my_team_members.length; i++) {
|
||||||
if (this.my_team_members.hasOwnProperty(index)) {
|
if (this.my_team_members[i].team_id === teamId) {
|
||||||
if (this.my_team_members[index].team_id === teamId) {
|
this.my_team_members.splice(i, 1);
|
||||||
Reflect.deleteProperty(this.my_team_members, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user