BigW Consortium Gitlab

Commit 76ef4f02 by Regis

diff updates from API to DOM

parent cb35c5e1
...@@ -8,27 +8,20 @@ ...@@ -8,27 +8,20 @@
class PipelineUpdater { class PipelineUpdater {
constructor(pipelines) { constructor(pipelines) {
this.pipelines = pipelines; this.pipelines = pipelines;
this.updateClone = (update, newPipe) => {
update.forEach((pipe) => {
if (pipe.id === newPipe.id) pipe = Object.assign({}, pipe, newPipe);
});
};
this.currentPageSlicer = (update) => {
if (update.length < PAGINATION_LIMIT) return update;
return update.slice(0, SLICE_LIMIT);
};
} }
updatePipelines(apiResponse) { updatePipelines(apiResponse) {
const update = this.pipelines.slice(0); const update = this.pipelines.slice(0);
apiResponse.pipelines.forEach((newPipe) => { apiResponse.pipelines.forEach((newPipe, i) => {
if (newPipe.commit) { if (newPipe.commit) {
update.unshift(newPipe); update.unshift(newPipe);
} else { } else {
this.updateClone(update, newPipe); const newMerge = Object.assign({}, update[i], newPipe);
update[i] = newMerge;
} }
}); });
return this.currentPageSlicer(update); if (update.length < PAGINATION_LIMIT) return update;
return update.slice(0, SLICE_LIMIT);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment