Skip to content

Commit

Permalink
fixed team switching (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-aschlackman authored Jan 23, 2024
1 parent baecd42 commit 43ceea9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/app/components/player/player.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,18 @@ export class PlayerComponent implements OnInit, OnDestroy {

/**
* Set the primary team instance by the team Guid. This is only valid when a user belongs to multiple
* teams. If a new primary team is set int he database, the page must be reloaded
* teams. If a new primary team is set in the database, the page must be reloaded
* @param teamId
*/
setPrimaryTeam(newTeamId) {
combineLatest([of(newTeamId), this.data$])
combineLatest([of(newTeamId), this.data$, this.user$])
.pipe(
switchMap(([newTeamId, data]) => {
switchMap(([newTeamId, data, user]) => {
if (newTeamId !== data.team.id) {
this.addParam({ teamId: newTeamId });
return this.viewsService.setPrimaryTeamId(
data.user.profile.id,
newTeamId
);
return this.viewsService
.setPrimaryTeamId(user.profile.sub, newTeamId)
.pipe(tap(() => window.location.reload()));
} else {
return of(EMPTY);
}
Expand Down

0 comments on commit 43ceea9

Please sign in to comment.