diff --git a/src/components/HOCs/WithCurrentTask/WithCurrentTask.jsx b/src/components/HOCs/WithCurrentTask/WithCurrentTask.jsx index 8ed3ebb55..5420d7072 100644 --- a/src/components/HOCs/WithCurrentTask/WithCurrentTask.jsx +++ b/src/components/HOCs/WithCurrentTask/WithCurrentTask.jsx @@ -231,15 +231,20 @@ export const mapDispatchToProps = (dispatch, ownProps) => { // Wait for all parallel tasks to complete await Promise.all(parallelTasks); - // Handle next task loading - this needs to be sequential + // Handle next task loading - this needs to be sequential. + // challengeIdFromRoute falls back to props.challengeId, and ownProps + // carries one only when the route does (/challenge/:challengeId/task/ + // :taskId). On the bare /task/:taskId route it doesn't, so seed it + // with the id the caller already handed us. + const nextTaskProps = { ...ownProps, challengeId }; if (taskLoadBy) { // Start loading the next task from the challenge. const loadNextTask = Number.isFinite(requestedNextTask) - ? await nextRequestedTask(dispatch, ownProps, requestedNextTask) - : await nextRandomTask(dispatch, ownProps, taskId, taskLoadBy); + ? await nextRequestedTask(dispatch, nextTaskProps, requestedNextTask) + : await nextRandomTask(dispatch, nextTaskProps, taskId, taskLoadBy); try { - await visitNewTask(dispatch, ownProps, taskId, loadNextTask); + await visitNewTask(dispatch, nextTaskProps, taskId, loadNextTask); } catch (error) { ownProps.history.push(`/browse/challenges/${challengeId}`); } @@ -287,13 +292,15 @@ export const mapDispatchToProps = (dispatch, ownProps) => { dispatch(addTaskComment(taskId, comment)); } + // See completeTask above for why challengeId has to be seeded here + const nextTaskProps = { ...ownProps, challengeId }; if (taskLoadBy === TaskLoadMethod.proximity && requestedNextTask) { - nextRequestedTask(dispatch, ownProps, requestedNextTask).then((newTask) => - visitNewTask(dispatch, ownProps, taskId, newTask), + nextRequestedTask(dispatch, nextTaskProps, requestedNextTask).then((newTask) => + visitNewTask(dispatch, nextTaskProps, taskId, newTask), ); } else { - nextRandomTask(dispatch, ownProps, taskId, taskLoadBy).then((newTask) => - visitNewTask(dispatch, ownProps, taskId, newTask), + nextRandomTask(dispatch, nextTaskProps, taskId, taskLoadBy).then((newTask) => + visitNewTask(dispatch, nextTaskProps, taskId, newTask), ); } }, diff --git a/src/components/TaskPane/TaskPane.jsx b/src/components/TaskPane/TaskPane.jsx index a0da3f055..ac65a719b 100644 --- a/src/components/TaskPane/TaskPane.jsx +++ b/src/components/TaskPane/TaskPane.jsx @@ -605,9 +605,17 @@ export class TaskPane extends Component { diff --git a/src/services/Task/LockConflict.js b/src/services/Task/LockConflict.js index 285369c15..a7f0a44a4 100644 --- a/src/services/Task/LockConflict.js +++ b/src/services/Task/LockConflict.js @@ -15,6 +15,7 @@ export const getLockConflict = (error) => { return { lockedTaskId: details.lockedTaskId, + parentId: typeof details.parentId === "number" ? details.parentId : null, parentName: details.parentName ?? null, bundledTasks: details.bundledTasks ?? [], startedAt: details.startedAt ?? null, diff --git a/src/services/Task/LockConflict.test.js b/src/services/Task/LockConflict.test.js index 5973737b1..5e7b889ed 100644 --- a/src/services/Task/LockConflict.test.js +++ b/src/services/Task/LockConflict.test.js @@ -22,6 +22,7 @@ describe("getLockConflict", () => { details: { message: "User 1 already holds a lock on item 123", lockedTaskId: 123, + parentId: 42, parentName: "Some Challenge", bundledTasks: [124, 125], startedAt: "2026-01-01T00:00:00Z", @@ -30,6 +31,7 @@ describe("getLockConflict", () => { expect(getLockConflict(error)).toEqual({ lockedTaskId: 123, + parentId: 42, parentName: "Some Challenge", bundledTasks: [124, 125], startedAt: "2026-01-01T00:00:00Z", @@ -37,7 +39,7 @@ describe("getLockConflict", () => { }); }); - it("defaults parentName/bundledTasks/startedAt when absent", () => { + it("defaults parentId/parentName/bundledTasks/startedAt when absent", () => { const error = { response: { status: 409 }, details: { message: "conflict", lockedTaskId: 123 }, @@ -45,6 +47,7 @@ describe("getLockConflict", () => { expect(getLockConflict(error)).toEqual({ lockedTaskId: 123, + parentId: null, parentName: null, bundledTasks: [], startedAt: null,