From 630582c4e87e142766b075aa55bfe8a7a8a2a88e Mon Sep 17 00:00:00 2001 From: Meelap Shah Date: Wed, 29 Mar 2017 14:59:19 -0400 Subject: [PATCH] transactionally update job summaries We should only cause the view to re-render once the entire job summaries response has been processed. --- .../resources/ui/stores/JobSummaryStore.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/resources/ui/stores/JobSummaryStore.js b/src/main/resources/ui/stores/JobSummaryStore.js index 2a553eec9..7bc39ae73 100644 --- a/src/main/resources/ui/stores/JobSummaryStore.js +++ b/src/main/resources/ui/stores/JobSummaryStore.js @@ -1,4 +1,4 @@ -import {observable, computed, autorun} from 'mobx'; +import {observable, computed, runInAction} from 'mobx'; import JobSummaryModel from '../models/JobSummaryModel' import $ from 'jquery' @@ -81,18 +81,20 @@ export class JobSummaryStore { this.isLoading = true; var otherThis = this; $.getJSON('v1/scheduler/jobs/summary').done(function(resp) { - var serverJobNames = new Set(); - resp.jobs.forEach(json => { - serverJobNames.add(json.name) - otherThis.updateJobSummaryFromServer(json) - }); + runInAction("update job summaries", () => { + var serverJobNames = new Set(); + resp.jobs.forEach(json => { + serverJobNames.add(json.name) + otherThis.updateJobSummaryFromServer(json) + }); - // Check for jobs which exist here, but not on the server - otherThis.jobSummarys.filter(function(j) { - return !serverJobNames.has(j.name) - }).forEach(j => j.destroy()) + // Check for jobs which exist here, but not on the server + otherThis.jobSummarys.filter(function(j) { + return !serverJobNames.has(j.name) + }).forEach(j => j.destroy()) - otherThis.isLoading = false; + otherThis.isLoading = false; + }); }).fail(function() { otherThis.isLoading = false; });