[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) {
|
async function initTeamOrRedirect(team: Team) {
|
||||||
try {
|
const {data: joinedTeam, error} = await props.initializeTeam(team) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
||||||
await props.initializeTeam(team);
|
if (error) {
|
||||||
setTeam(team);
|
|
||||||
} catch (error) {
|
|
||||||
history.push('/error?type=team_not_found');
|
history.push('/error?type=team_not_found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (joinedTeam) {
|
||||||
|
setTeam(joinedTeam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function joinTeamOrRedirect(teamNameParam: string, joinedOnFirstLoad: boolean) {
|
async function joinTeamOrRedirect(teamNameParam: string, joinedOnFirstLoad: boolean) {
|
||||||
setTeam(null);
|
setTeam(null);
|
||||||
|
|
||||||
try {
|
const {data: joinedTeam, error} = await props.joinTeam(teamNameParam, joinedOnFirstLoad) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
||||||
const {data: joinedTeam} = await props.joinTeam(teamNameParam, joinedOnFirstLoad) as ActionResult<Team, ServerError>; // Fix in MM-46907;
|
if (error) {
|
||||||
if (joinedTeam) {
|
|
||||||
setTeam(joinedTeam);
|
|
||||||
} else {
|
|
||||||
throw new Error('Unable to join team');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
history.push('/error?type=team_not_found');
|
history.push('/error?type=team_not_found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (joinedTeam) {
|
||||||
|
setTeam(joinedTeam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user