Skip to content

Commit

Permalink
Merge pull request #399 from LibCrowds/dev
Browse files Browse the repository at this point in the history
Fix loading of new tasks into presenter (re #378)
  • Loading branch information
alexandermendes authored Oct 13, 2017
2 parents 04522d5 + 3a1074d commit 6b8f122
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/pages/collection/Presenter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="presenter">
<component
:is="presenter"
v-if="project && tasks.length"
v-if="project"
:project="project"
:tasks="tasks"
:currentUser="currentUser"
Expand Down Expand Up @@ -89,27 +89,16 @@ export default {
this.project = data.project
this.title = this.project.name
this.description = this.project.description
this.loadTasks()
this.loadNewTasks()
},
/**
* Return the URL to load the next set of tasks
* Load the next set of tasks, if there are less than 10 ready.
*/
getLoadTasksUrl () {
loadNewTasks () {
const endpoint = `/api/project/${this.project.id}/newtask`
let q = 'limit=10'
if (this.tasks.length) {
const lastTask = this.tasks[this.tasks.length - 1]
q += `&last_id=${lastTask.id}`
}
return `${endpoint}?${q}`
},
/**
* Load the next set of tasks.
*/
loadTasks () {
const url = this.getLoadTasksUrl()
const query = `limit=10&offset=${this.tasks.length}`
const url = `${endpoint}?${query}`
pybossaApi.get(url).then(r => {
if (isEmpty(r.data)) {
this.handleCompletion()
Expand Down Expand Up @@ -201,7 +190,9 @@ export default {
})
pybossaApi.post(`/api/taskrun`, taskrun).then(r => {
this.removeTask(taskId)
this.loadTasks()
if (this.tasks.length < 10) {
this.loadNewTasks()
}
if (hasParticipated === 'true') {
this.$store.dispatch('NOTIFY', {
msg: 'Answer saved, thank you!',
Expand Down

0 comments on commit 6b8f122

Please sign in to comment.