Skip to content

Commit

Permalink
Auto merge of #2776 - Turbo87:get, r=locks
Browse files Browse the repository at this point in the history
Remove unnecessary `this.get()` calls

These should not be necessary anymore AFAICT

Resolves #1795

r? `@locks`
  • Loading branch information
bors committed Oct 20, 2020
2 parents 9102eb2 + 21d2bc3 commit f0c0275
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Expand Up @@ -21,7 +21,6 @@ module.exports = {

'ember/no-classic-classes': 'error',
'ember/no-empty-attrs': 'off',
'ember/no-get': 'off',
'ember/require-computed-property-dependencies': 'off',

'import-helpers/order-imports': [
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/crate/owners.js
Expand Up @@ -42,11 +42,11 @@ export default class CrateOwnersController extends Controller {
switch (owner.kind) {
case 'user':
this.set('removed', `User ${owner.get('login')} removed as crate owner`);
this.get('crate.owner_user').removeObject(owner);
this.crate.owner_user.removeObject(owner);
break;
case 'team':
this.set('removed', `Team ${owner.get('display_name')} removed as crate owner`);
this.get('crate.owner_team').removeObject(owner);
this.crate.owner_team.removeObject(owner);
break;
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/crate/version.js
Expand Up @@ -28,7 +28,7 @@ export default class CrateVersionController extends Controller {

@computed('crate.owner_user', 'session.currentUser.id')
get isOwner() {
return this.get('crate.owner_user').findBy('id', this.get('session.currentUser.id'));
return this.crate.owner_user.findBy('id', this.session.currentUser?.id);
}

@readOnly('crate.versions') sortedVersions;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/crate/versions.js
Expand Up @@ -7,6 +7,6 @@ export default class CrateVersionsController extends Controller {

@computed('model.owner_user', 'session.currentUser.id')
get isOwner() {
return this.get('model.owner_user').findBy('id', this.get('session.currentUser.id'));
return this.model.owner_user.findBy('id', this.session.currentUser?.id);
}
}
4 changes: 2 additions & 2 deletions app/controllers/dashboard.js
Expand Up @@ -29,12 +29,12 @@ export default class DashboardController extends Controller {

@computed('myCrates.[]')
get hasMoreCrates() {
return this.get('myCrates.length') > TO_SHOW;
return this.myCrates.length > TO_SHOW;
}

@computed('myFollowing.[]')
get hasMoreFollowing() {
return this.get('myFollowing.length') > TO_SHOW;
return this.myFollowing.length > TO_SHOW;
}

@task(function* () {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/index.js
Expand Up @@ -12,7 +12,7 @@ export default class IndexController extends Controller {

@computed('dataTask.{lastSuccessful,isRunning}')
get hasData() {
return this.get('dataTask.lastSuccessful') && !this.get('dataTask.isRunning');
return this.dataTask.lastSuccessful && !this.dataTask.isRunning;
}

@(task(function* () {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/me/index.js
Expand Up @@ -28,7 +28,7 @@ export default class MeIndexController extends Controller {
}

setAllEmailNotifications(value) {
this.get('ownedCrates').forEach(c => {
this.ownedCrates.forEach(c => {
c.set('email_notifications', value);
});
}
Expand All @@ -41,7 +41,7 @@ export default class MeIndexController extends Controller {
await ajax(`/api/v1/me/email_notifications`, {
method: 'PUT',
body: JSON.stringify(
this.get('ownedCrates').map(c => ({
this.ownedCrates.map(c => ({
id: parseInt(c.id, 10),
email_notifications: c.email_notifications,
})),
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/search.js
Expand Up @@ -16,12 +16,12 @@ export default class SearchController extends Controller {

@computed('dataTask.{lastSuccessful,isRunning}')
get hasData() {
return this.get('dataTask.lastSuccessful') || !this.get('dataTask.isRunning');
return this.dataTask.lastSuccessful || !this.dataTask.isRunning;
}

@computed('dataTask.{lastSuccessful,isRunning}')
get firstResultPending() {
return !this.get('dataTask.lastSuccessful') && this.get('dataTask.isRunning');
return !this.dataTask.lastSuccessful && this.dataTask.isRunning;
}

@readOnly('model.meta.total') totalItems;
Expand Down
3 changes: 1 addition & 2 deletions app/models/team.js
Expand Up @@ -18,8 +18,7 @@ export default class Team extends Model {
org_name;

@computed('name', 'org_name', function () {
let { name, org_name } = this.getProperties('name', 'org_name');
return `${org_name}/${name}`;
return `${this.org_name}/${this.name}`;
})
display_name;
}
6 changes: 4 additions & 2 deletions app/models/version.js
Expand Up @@ -29,7 +29,8 @@ export default class Version extends Model {
@alias('loadAuthorsTask.last.value') authorNames;

@(task(function* () {
let authors = yield this.get('authors');
// trigger the async relationship to load the content
let authors = yield this.authors;
return authors.meta.names;
}).keepLatest())
loadAuthorsTask;
Expand All @@ -39,7 +40,8 @@ export default class Version extends Model {
@alias('loadDepsTask.last.value.dev') devDependencies;

@(task(function* () {
let dependencies = yield this.get('dependencies');
// trigger the async relationship to load the content
let dependencies = yield this.dependencies;

let normal = dependencies.filterBy('kind', 'normal').uniqBy('crate_id');
let build = dependencies.filterBy('kind', 'build').uniqBy('crate_id');
Expand Down
2 changes: 1 addition & 1 deletion app/routes/me/crates.js
Expand Up @@ -7,7 +7,7 @@ export default class MeCratesRoute extends AuthenticatedRoute {
};

model(params) {
params.user_id = this.get('session.currentUser.id');
params.user_id = this.session.currentUser.id;
return this.store.query('crate', params);
}
}

0 comments on commit f0c0275

Please sign in to comment.