Skip to content

Commit

Permalink
Fix jobs list and refetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Mar 4, 2016
1 parent a173ddf commit 5dab7fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/app/routes/Jobs/components/Jobs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const bindableActions = {
const fetchOptions = {
fetchAction: 'fetchJobs',
isPrimed({ jobs }) {
return !!jobs.length;
return jobs.length > 1;
}
};

Expand Down
2 changes: 1 addition & 1 deletion common/app/routes/Jobs/redux/fetch-jobs-saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default ({ services }) => ({ dispatch }) => next => {
const { payload: id } = action;
const data = { service: 'jobs' };
if (id) {
data.id = id;
data.params = { id };
}

return services.readService$(data)
Expand Down
13 changes: 8 additions & 5 deletions server/services/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ export default function getJobServices(app) {
});

Job.create(job, (err, savedJob) => {
cb(err, savedJob);
cb(err, savedJob.toJSON());
});
},
read(req, resource, params, config, cb) {
const id = params ? params.id : null;
console.log('params', params);
if (id) {
return Job.findById(id, cb);
return Job.findById(id)
.then(job => cb(null, job.toJSON()))
.catch(cb);
}
Job.find(whereFilt, (err, jobs) => {
cb(err, jobs.map(job => job.toJSON()));
});
Job.find(whereFilt)
.then(jobs => cb(null, jobs.map(job => job.toJSON())))
.catch(cb);
}
};
}

0 comments on commit 5dab7fd

Please sign in to comment.