Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in reducers that load bestSolutions fixed. #157

Merged
merged 1 commit into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const AssignmentTableRow = ({
<td>
<ResourceRenderer resource={bestSubmission}>
{data =>
data.lastSubmission
data && data.lastSubmission
? <span>
{data.lastSubmission.evaluation.points}
{data.bonusPoints > 0 &&
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Group/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ class Group extends Component {
}

componentWillReceiveProps(newProps) {
const { params: { groupId } } = this.props;
const { params: { groupId }, userId, isSuperAdmin } = this.props;

if (groupId !== newProps.params.groupId) {
if (
groupId !== newProps.params.groupId ||
userId !== newProps.userId ||
isSuperAdmin !== newProps.isSuperAdmin
) {
newProps.loadAsync(newProps.userId, newProps.isSuperAdmin);
return;
}
Expand Down
35 changes: 27 additions & 8 deletions src/redux/modules/groupResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,37 @@ const reducer = handleActions(
[additionalActionTypes.BEST_SUBMISSION_PENDING]: (
state,
{ payload, meta: { userId, assignmentId } }
) => state.setIn(['resources', assignmentId, userId], createRecord()),
) =>
userId !== undefined
? state.setIn(['resources', assignmentId, userId], createRecord())
: state,

[additionalActionTypes.BEST_SUBMISSION_FULFILLED]: (
state,
{ payload = {}, meta: { assignmentId, userId } }
) =>
state
.setIn(['resources', assignmentId, userId, 'data'], fromJS(payload))
.setIn(
['resources', assignmentId, userId, 'state'],
resourceStatus.FULFILLED
)
) => {
if (userId !== undefined) {
// update single-user record
return state
.setIn(['resources', assignmentId, userId, 'data'], fromJS(payload))
.setIn(
['resources', assignmentId, userId, 'state'],
resourceStatus.FULFILLED
);
} else {
// Update for each user in the payload
for (const uId in payload) {
state = state.setIn(
['resources', assignmentId, uId],
createRecord({
data: fromJS(payload[uId]),
state: resourceStatus.FULFILLED
})
);
}
return state;
}
}
}),
initialState
);
Expand Down