Skip to content

Commit

Permalink
reduce redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Dec 3, 2024
1 parent 224e784 commit 35705d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
// Fetch up to threshold+1 individual tasks (eg. 1001 tasks)
this.props.fetchBoundedTaskMarkers(searchCriteria, UNCLUSTER_THRESHOLD + 1, !storeTasks, ignoreLocked).then(results => {
if (currentFetchId >= this.state.fetchId) {
const totalCount = results.length
// If we retrieved 1001 tasks then there might be more tasks and
// they should be clustered. So fetch as clusters
// (unless we are zoomed all the way in already)
if (results.totalCount > UNCLUSTER_THRESHOLD &&
if (totalCount > UNCLUSTER_THRESHOLD &&
_get(this.props, 'criteria.zoom', 0) < MAX_ZOOM) {
this.props.fetchTaskClusters(challengeId, searchCriteria, 25, overrideDisable
).then(results => {
Expand All @@ -127,8 +128,8 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
})
}
else {
this.setState({clusters: results.tasks, loading: false,
taskCount: results.totalCount})
this.setState({clusters: results, loading: false,
taskCount: totalCount})
}
}
}).catch(error => {
Expand Down
8 changes: 2 additions & 6 deletions src/services/Task/BoundedTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,13 @@ export const fetchBoundedTaskMarkers = function(criteria, limit = 50, skipDispat
}
).execute().then(({ result }) => {
let tasks = result ? Object.values(result) : [];
const totalCount = tasks.length
tasks = tasks.map(task => Object.assign(task, task.pointReview))

if (!skipDispatch) {
dispatch(receiveBoundedTasks(tasks, RequestStatus.success, fetchId, totalCount))
dispatch(receiveBoundedTasks(tasks, RequestStatus.success, fetchId, tasks.length))
}

return {
tasks,
totalCount
}
return tasks
}).catch(error => {
dispatch(receiveBoundedTasks([], RequestStatus.error, fetchId))
dispatch(addError(AppErrors.boundedTask.fetchFailure))
Expand Down

0 comments on commit 35705d0

Please sign in to comment.