Skip to content

Commit 5de89d2

Browse files
committed
routes/crate/version: Replace afterModel() hack with computed property
1 parent abe1b30 commit 5de89d2

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

app/controllers/crate/version.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export default Ember.Controller.extend({
1111
downloadsContext: Ember.computed('requestedVersion', 'model', 'crate', function() {
1212
return this.get('requestedVersion') ? this.get('model') : this.get('crate');
1313
}),
14-
extraDownloads: Ember.computed('downloads.meta.extra_downloads', function() {
15-
return this.get('downloads.meta.extra_downloads') || [];
14+
downloads: computed.alias('downloadsContext.version_downloads'),
15+
extraDownloads: Ember.computed('downloads.content.meta.extra_downloads', function() {
16+
return this.get('downloads.content.meta.extra_downloads') || [];
1617
}),
1718

1819
fetchingFollowing: true,

app/routes/crate/version.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ export default Ember.Route.extend({
4040
});
4141
},
4242

43-
// can't do this in setupController because it won't be called
44-
// when going from "All Versions" to the current version
45-
afterModel(model) {
46-
this._super(...arguments);
47-
48-
const controller = this.controllerFor(this.routeName);
49-
const context = controller.get('requestedVersion') ? model : this.modelFor('crate');
50-
51-
context.get('version_downloads').then(downloads => {
52-
controller.set('downloads', downloads);
53-
});
54-
},
55-
5643
serialize(model) {
5744
let version_num = model ? model.get('num') : '';
5845
return { version_num };

0 commit comments

Comments
 (0)