Skip to content

Commit

Permalink
remove completingtask conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Nov 15, 2024
1 parent cfcd39f commit 3a30303
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 45 deletions.
15 changes: 4 additions & 11 deletions src/components/HOCs/WithTaskBundle/WithTaskBundle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import {
export function WithTaskBundle(WrappedComponent) {
return class extends Component {
state = {
loading: false,
bundleEditsDisabled: false,
initialBundle: null,
taskBundle: null,
completingTask: null,
bundleEditsDisabled: false,
selectedTasks: [],
resetSelectedTasks: null,
errorMessage: null
errorMessage: null,
loading: false,
}

async componentDidMount() {
Expand All @@ -43,7 +42,7 @@ export function WithTaskBundle(WrappedComponent) {
async componentDidUpdate(prevProps) {
const { task } = this.props
if (_get(task, 'id') !== _get(prevProps, 'task.id')) {
this.setState({ selectedTasks: [], taskBundle: null, initialBundle: null, loading: false, completingTask: null })
this.setState({ selectedTasks: [], taskBundle: null, initialBundle: null, loading: false })
if (_isFinite(_get(task, 'bundleId'))) {
await this.fetchBundle(task.bundleId)
}
Expand Down Expand Up @@ -180,10 +179,6 @@ export function WithTaskBundle(WrappedComponent) {
this.resetSelectedTasks()
}

setCompletingTask = task => {
this.setState({ selectedTasks: [], completingTask: task })
}

updateTaskBundle = async () => {
const { taskBundle, initialBundle } = this.state
if (taskBundle || initialBundle) {
Expand All @@ -207,8 +202,6 @@ export function WithTaskBundle(WrappedComponent) {
taskBundle={this.state.taskBundle}
initialBundle={this.state.initialBundle}
taskBundleLoading={this.state.loading}
setCompletingTask={this.setCompletingTask}
completingTask={this.props.completingTask}
createTaskBundle={this.createTaskBundle}
updateTaskBundle={this.updateTaskBundle}
resetTaskBundle={this.resetTaskBundle}
Expand Down
1 change: 0 additions & 1 deletion src/components/ReviewTaskControls/ReviewTaskControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class ReviewTaskControls extends Component {
if(this.state.tags) {
this.props.saveTaskTags(this.props.task, this.state.tags)
}
this.props.setCompletingTask(this.props.task.id)

const history = _cloneDeep(this.props.history)
_merge(_get(history, 'location.state', {}), alternateCriteria)
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReviewTaskPane/ReviewTaskPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class ReviewTaskPane extends Component {
/>
</MediaQuery>
<MediaQuery query="(max-width: 1023px)">
<MapPane completingTask={this.state.completingTask}>
<MapPane>
<TaskMap isMobile
task={this.props.task}
challenge={this.props.task.parent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ export class ActiveTaskControls extends Component {
this.props.saveTaskTags(this.props.task, this.state.tags)
}

this.props.setCompletingTask(this.props.task.id)

const revisionSubmission = this.props.task.reviewStatus === TaskReviewStatus.rejected

if (!_isUndefined(this.state.submitRevision)) {
Expand Down
20 changes: 9 additions & 11 deletions src/components/TaskPane/TaskMap/TaskMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ export const TaskMapContent = (props) => {

useMapEvents({
moveend: () => {
if (props.task.id !== props.completingTask) {
const bounds = map.getBounds()
const zoom = map.getZoom()
props.setTaskMapBounds(props.task.id, bounds, zoom, false)
if (props.setWorkspaceContext) {
props.setWorkspaceContext({
taskMapTask: props.task,
taskMapBounds: bounds,
taskMapZoom: zoom
})
}
const bounds = map.getBounds()
const zoom = map.getZoom()
props.setTaskMapBounds(props.task.id, bounds, zoom, false)
if (props.setWorkspaceContext) {
props.setWorkspaceContext({
taskMapTask: props.task,
taskMapBounds: bounds,
taskMapZoom: zoom
})
}
},
})
Expand Down
21 changes: 2 additions & 19 deletions src/components/TaskPane/TaskPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,7 @@ export class TaskPane extends Component {
needsReview, requestedNextTask, osmComment, tagEdits, taskBundle) => {
this.props.completeTask(task, challengeId, taskStatus, comment, tags, taskLoadBy, userId,
needsReview, requestedNextTask, osmComment, tagEdits,
this.state.completionResponses, taskBundle).then(() => {
this.clearCompletingTask()
})
}

clearCompletingTask = () => {
// Clear on next tick to give our animation transition a chance to clean up.
setTimeout(() => {
this.props.setCompletingTask(null)
}, 0)
this.state.completionResponses, taskBundle)
}

setCompletionResponse = (propertyName, value) => {
Expand Down Expand Up @@ -387,23 +378,15 @@ export class TaskPane extends Component {
</div>
}
completeTask={this.completeTask}
completingTask={this.props.completingTask}
setCompletionResponse={this.setCompletionResponse}
setNeedsResponses={this.setNeedsResponses}
completionResponses={completionResponses}
needsResponses={this.state.needsResponses}
templateRevision={isCompletionStatus(this.props.task.status)}
/>
{this.props.completingTask && this.props.completingTask === this.props.task.id &&
<div
className="mr-fixed mr-top-0 mr-bottom-0 mr-left-0 mr-right-0 mr-z-200 mr-bg-blue-firefly-75 mr-flex mr-justify-center mr-items-center"
>
<BusySpinner big inline />
</div>
}
</MediaQuery>
<MediaQuery query="(max-width: 1023px)">
<MapPane completingTask={this.props.completingTask}>
<MapPane>
<TaskMap isMobile
task={this.props.task}
challenge={this.props.task.parent}
Expand Down

0 comments on commit 3a30303

Please sign in to comment.