Ensure startup/load image is removed if you hit an error on first load

This commit is contained in:
John Cowen 2018-06-13 14:15:08 +01:00
parent 597538354f
commit 7f7325e05e
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,9 @@ import { hash } from 'rsvp';
import { get } from '@ember/object';
import { next } from '@ember/runloop';
const $html = document.documentElement;
const removeLoading = function() {
return $html.classList.remove('ember-loading');
};
export default Route.extend({
init: function() {
this._super(...arguments);
@ -24,7 +27,7 @@ export default Route.extend({
const controller = this.controllerFor('application');
controller.setProperties(model);
transition.promise.finally(function() {
$html.classList.remove('ember-loading');
removeLoading();
controller.setProperties({
loading: false,
dc: model.dc,
@ -51,11 +54,13 @@ export default Route.extend({
dc: error.status.toString().indexOf('5') !== 0 ? get(this, 'repo').getActive() : null,
})
.then(model => {
removeLoading();
next(() => {
this.controllerFor('error').setProperties(model);
});
})
.catch(e => {
removeLoading();
next(() => {
this.controllerFor('error').setProperties({ error: error });
});