From 819ed079814f948ead7306adcc90f5a197ef8dee Mon Sep 17 00:00:00 2001 From: Roland Bernard <rolbernard@unibz.it> Date: Wed, 2 Jun 2021 17:20:28 +0200 Subject: [PATCH] Quick fix for a fatal error with the teams page --- client/src/pages/Tasks/TaskDetail/index.tsx | 2 +- client/src/pages/Teams/index.tsx | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/src/pages/Tasks/TaskDetail/index.tsx b/client/src/pages/Tasks/TaskDetail/index.tsx index 29308d2..d49d84d 100644 --- a/client/src/pages/Tasks/TaskDetail/index.tsx +++ b/client/src/pages/Tasks/TaskDetail/index.tsx @@ -49,7 +49,7 @@ export default function TaskDetail() { }); getTaskAssignees(taskId).then(setAssignees); setAssignment(task.assigned.find(a => a.user === userId)) - }).catch(() => history.goBack()); + }).catch(() => {}); }, [taskId, userId, history]); if (task) { diff --git a/client/src/pages/Teams/index.tsx b/client/src/pages/Teams/index.tsx index c292e10..4451909 100644 --- a/client/src/pages/Teams/index.tsx +++ b/client/src/pages/Teams/index.tsx @@ -30,20 +30,19 @@ export default function Teams() { const { teamId: teamParamId } = useParams<Params>(); const lastTeam = sessionStorage.getItem('last-selected-team'); const teamId = teamParamId ?? lastTeam ?? teams?.[0]?.id - sessionStorage.setItem('last-selected-team', teamId); + if (teamId) { + sessionStorage.setItem('last-selected-team', teamId); + } let currentTeam = teams?.find(team => team.id === teamId); useEffect(() => { - if (teams && (!currentTeam || !teamParamId)) { - if (teams.length > 0) { - // if no team is defined, take the first one - history.replace('/teams/' + teamId); - } else { - history.push('/introduction'); - } + if (teamId && !teamParamId) { + history.replace('/teams/' + teamId); + } else if (teams && teams.length === 0) { + history.push('/introduction'); } - }); + }, [teamId, teamParamId, teams, history]); useEffect(() => { getTeams().then(setTeams); -- GitLab