Skip to content

Commit cc9eca0

Browse files
author
Vikas Agarwal
committed
fix: fixed the side effect, of last refactoring, on Launch New action
1 parent 5f01d70 commit cc9eca0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/actions/challenges.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,19 @@ export function loadChallenges (projectId, status, filterChallengeName = null) {
168168
*/
169169
export function loadChallengeDetails (projectId, challengeId) {
170170
return (dispatch, getState) => {
171-
return dispatch({
172-
type: LOAD_CHALLENGE_DETAILS,
173-
payload: fetchChallenge(challengeId).then((challenge) => {
174-
// TODO remove this unncessary check, or better utilize the the case when given project id
175-
// does not match with challenge's project id
176-
if (challenge.projectId === projectId) {
177-
dispatch(loadProject(projectId))
178-
}
179-
return challenge
171+
if (challengeId) {
172+
return dispatch({
173+
type: LOAD_CHALLENGE_DETAILS,
174+
payload: fetchChallenge(challengeId).then((challenge) => {
175+
// TODO remove this unncessary check, or better utilize the the case when given project id
176+
// does not match with challenge's project id
177+
if (challenge.projectId === projectId) {
178+
dispatch(loadProject(projectId))
179+
}
180+
return challenge
181+
})
180182
})
181-
})
183+
}
182184
}
183185
}
184186

0 commit comments

Comments
 (0)