From 3d93398eae8efc4699a1b80ba39aee071542431b Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 17 Oct 2017 19:18:04 -0700 Subject: [PATCH] Don't double render, also don't render infinitely See https://github.com/emberjs/ember.js/issues/13948 --- ui/app/components/allocation-row.js | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ui/app/components/allocation-row.js b/ui/app/components/allocation-row.js index 9606fae8d..a258f5b24 100644 --- a/ui/app/components/allocation-row.js +++ b/ui/app/components/allocation-row.js @@ -45,19 +45,25 @@ export default Component.extend({ // being resolved through the store (store.findAll('job')). The // workaround is to persist the jobID as a string on the allocation // and manually re-link the two records here. - - run.next(() => { - const allocation = this.get('allocation'); - const job = this.get('store').peekRecord('job', allocation.get('originalJobId')); - if (job) { - allocation.set('job', job); - } else { - this.get('store') - .findRecord('job', allocation.get('originalJobId')) - .then(job => { - allocation.set('job', job); - }); - } - }); + run.scheduleOnce('afterRender', this, qualifyJob); }, }); + +function qualifyJob() { + const allocation = this.get('allocation'); + if (allocation.get('originalJobId')) { + const job = this.get('store').peekRecord('job', allocation.get('originalJobId')); + if (job) { + allocation.setProperties({ + job, + originalJobId: null, + }); + } else { + this.get('store') + .findRecord('job', allocation.get('originalJobId')) + .then(job => { + allocation.set('job', job); + }); + } + } +}