Skip to content

Commit

Permalink
persist adjusted filters in next task review workflow (#2319)
Browse files Browse the repository at this point in the history
* fix selected next filtered challenge issue in review workflow

* make Next Filtered Task filters persist between tasks
  • Loading branch information
CollinBeczak authored May 12, 2024
1 parent c149d16 commit 58a1ca4
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/components/TaskConfirmationModal/TaskConfirmationModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,30 @@ export class TaskConfirmationModal extends Component {
this.props.setTags(value)
}

filterChange = (key, value, invert=false) => {
const criteria = _cloneDeep(this.currentFilters())
criteria.filters = criteria.filters || {}
criteria.filters[key] = value

if (key === "challenge") {
// If we are using a challenge filter then we need to cleanup
// the challengeId filter as it gets priority.
criteria.filters.challengeId = null
}

criteria.invertFields = criteria.invertFields || {}
criteria.invertFields[key] = invert
this.setState({criteria})
filterChange = (key, value, invert = false) => {
this.setState(prevState => {
const criteria = _cloneDeep(prevState.criteria)
criteria.filters = criteria.filters || {}
criteria.filters[key] = value

if (key === "challenge") {
// If we are using a challenge filter then we need to cleanup
// the challengeId filter as it gets priority.
criteria.filters.challengeId = null
}

criteria.invertFields = criteria.invertFields || {}
criteria.invertFields[key] = invert

return { criteria }
}, this.updateHistory)
}

updateHistory = () => {
const { criteria } = this.state
const currentState = _get(this.props.history, 'location.state', {})
const newState = _merge({}, currentState, criteria)
this.props.history.replace({ ...this.props.history.location, state: newState })
}

currentFilters = () => {
Expand Down

0 comments on commit 58a1ca4

Please sign in to comment.