[MM-55412] Use go-style error handling in team_controller (#25402)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e3087955b
Коммит
9cf84fb93f
@@ -150,26 +150,26 @@ function TeamController(props: Props) {
|
||||
}, []);
|
||||
|
||||
async function initTeamOrRedirect(team: Team) {
|
||||
try {
|
||||
await props.initializeTeam(team);
|
||||
setTeam(team);
|
||||
} catch (error) {
|
||||
const {data: joinedTeam, error} = await props.initializeTeam(team) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
||||
if (error) {
|
||||
history.push('/error?type=team_not_found');
|
||||
return;
|
||||
}
|
||||
if (joinedTeam) {
|
||||
setTeam(joinedTeam);
|
||||
}
|
||||
}
|
||||
|
||||
async function joinTeamOrRedirect(teamNameParam: string, joinedOnFirstLoad: boolean) {
|
||||
setTeam(null);
|
||||
|
||||
try {
|
||||
const {data: joinedTeam} = await props.joinTeam(teamNameParam, joinedOnFirstLoad) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
||||
if (joinedTeam) {
|
||||
setTeam(joinedTeam);
|
||||
} else {
|
||||
throw new Error('Unable to join team');
|
||||
}
|
||||
} catch (error) {
|
||||
const {data: joinedTeam, error} = await props.joinTeam(teamNameParam, joinedOnFirstLoad) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
||||
if (error) {
|
||||
history.push('/error?type=team_not_found');
|
||||
return;
|
||||
}
|
||||
if (joinedTeam) {
|
||||
setTeam(joinedTeam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user