From 35705d01ca4853fff94002a2543acddf1ffd2163 Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Tue, 3 Dec 2024 14:01:49 -0600 Subject: [PATCH] reduce redundancy --- .../WithChallengeTaskClusters.jsx | 7 ++++--- src/services/Task/BoundedTask.js | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/HOCs/WithChallengeTaskClusters/WithChallengeTaskClusters.jsx b/src/components/HOCs/WithChallengeTaskClusters/WithChallengeTaskClusters.jsx index 233300802..e9b338386 100644 --- a/src/components/HOCs/WithChallengeTaskClusters/WithChallengeTaskClusters.jsx +++ b/src/components/HOCs/WithChallengeTaskClusters/WithChallengeTaskClusters.jsx @@ -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 => { @@ -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 => { diff --git a/src/services/Task/BoundedTask.js b/src/services/Task/BoundedTask.js index fd0d922fd..a49c30391 100644 --- a/src/services/Task/BoundedTask.js +++ b/src/services/Task/BoundedTask.js @@ -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))