Skip to content

Commit

Permalink
fix limbo state after leaving last team
Browse files Browse the repository at this point in the history
closes #4026
  • Loading branch information
Steve-Mcl committed Jul 19, 2024
1 parent 940a813 commit d658e8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion frontend/src/pages/account/Teams/Teams.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
},
computed: {
...mapState('account', ['user', 'teams', 'settings']),
...mapState('account', ['teamMembership', 'team']),
teamCount () {
return this.teams ? this.teams.length : 0
}
Expand Down Expand Up @@ -64,7 +65,10 @@ export default {
try {
await teamApi.removeTeamMember(row.id, this.user.id)
alerts.emit(`${this.user.username} successfully removed from ${row.name}`, 'confirmation')
this.$store.dispatch('account/refreshTeams')
await this.$store.dispatch('account/refreshTeams')
if (!this.teamCount) {
await this.$store.dispatch('account/setTeam', null)
}
} catch (err) {
alerts.emit(`Failed to remove ${this.user.username} from ${row.name}: ${err.response.data.error}`, 'warning')
console.warn(err)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/store/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ const actions = {
return
}
} else {
if (!currentTeam || currentTeam.id === team.id) {
if (!currentTeam || currentTeam.id === team?.id) {
state.commit('clearPendingTeamChange')
return
}
}
if (team.id) {
if (team?.id) {
teamMembership = await teamApi.getTeamUserMembership(team.id)
}
state.commit('setTeam', team)
Expand Down

0 comments on commit d658e8b

Please sign in to comment.