Refactor routes
* Add specific dashboard route * Port application route to Octane * Fetch/sync contributors in application route, but only sync contributions in dashboard route for now
This commit is contained in:
+18
-22
@@ -1,39 +1,35 @@
|
|||||||
import { inject as service } from '@ember/service';
|
|
||||||
import Route from '@ember/routing/route';
|
import Route from '@ember/routing/route';
|
||||||
|
import { inject as service } from '@ember/service';
|
||||||
import { schedule } from '@ember/runloop';
|
import { schedule } from '@ember/runloop';
|
||||||
|
|
||||||
export default Route.extend({
|
export default class ApplicationRoute extends Route {
|
||||||
kredits: service(),
|
|
||||||
|
@service kredits;
|
||||||
|
|
||||||
beforeModel(/* transition */) {
|
beforeModel(/* transition */) {
|
||||||
const kredits = this.kredits;
|
const kredits = this.kredits;
|
||||||
|
|
||||||
return kredits.setup().then(() => {
|
return kredits.setup().then(() => {
|
||||||
kredits.get('kredits').preflightChecks().catch((error) => {
|
kredits.kredits.preflightChecks().catch((error) => {
|
||||||
console.error('Kredits preflight check failed!');
|
console.error('Kredits preflight check failed!');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log('Error initializing Kredits', error);
|
console.log('Error initializing Kredits', error);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
|
model() {
|
||||||
|
return this.kredits.loadInitialData().then(() => {
|
||||||
|
this.kredits.addContractEventHandlers()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
afterModel() {
|
afterModel() {
|
||||||
return this.kredits.loadInitialData()
|
if (this.kredits.contributorsNeedSync) {
|
||||||
.then(() => {
|
schedule('afterRender', this.kredits.syncContributors,
|
||||||
this.kredits.addContractEventHandlers();
|
this.kredits.syncContributors.perform);
|
||||||
})
|
}
|
||||||
.then(() => {
|
|
||||||
if (this.kredits.contributorsNeedSync) {
|
|
||||||
schedule('afterRender', this.kredits.syncContributors,
|
|
||||||
this.kredits.syncContributors.perform);
|
|
||||||
}
|
|
||||||
if (this.kredits.contributionsNeedSync) {
|
|
||||||
schedule('afterRender', this.kredits.syncContributions,
|
|
||||||
this.kredits.syncContributions.perform);
|
|
||||||
}
|
|
||||||
schedule('afterRender', this.kredits.fetchMissingContributions,
|
|
||||||
this.kredits.fetchMissingContributions.perform);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import Route from '@ember/routing/route';
|
||||||
|
import { schedule } from '@ember/runloop';
|
||||||
|
import { inject as service } from '@ember/service';
|
||||||
|
|
||||||
|
export default class DashboardRoute extends Route {
|
||||||
|
|
||||||
|
@service kredits;
|
||||||
|
|
||||||
|
afterModel() {
|
||||||
|
if (this.kredits.contributionsNeedSync) {
|
||||||
|
schedule('afterRender', this.kredits.syncContributions,
|
||||||
|
this.kredits.syncContributions.perform);
|
||||||
|
}
|
||||||
|
schedule('afterRender', this.kredits.fetchMissingContributions,
|
||||||
|
this.kredits.fetchMissingContributions.perform);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupTest } from 'ember-qunit';
|
||||||
|
|
||||||
|
module('Unit | Route | dashboard', function(hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
|
test('it exists', function(assert) {
|
||||||
|
let route = this.owner.lookup('route:dashboard');
|
||||||
|
assert.ok(route);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user