mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Fixed missing invite role name on team screen
no issue - removed the rename of `role_id` to `role` in the invite serialiser to let Ember Data do it's thing with the `invite.role` relationship - added a guard to the team screen background reloading to ensure that role data is present in the store before loading invites so that Ember Data doesn't trigger unnecessary requests to find missing relationship data
This commit is contained in:
parent
921d826da5
commit
d7375aab1a
@ -60,10 +60,9 @@ export default Controller.extend({
|
||||
backgroundUpdate: task(function* () {
|
||||
let users = this.fetchUsers.perform();
|
||||
let invites = this.fetchInvites.perform();
|
||||
let roles = this.fetchRoles.perform();
|
||||
|
||||
try {
|
||||
yield RSVP.all([users, invites, roles]);
|
||||
yield RSVP.all([users, invites]);
|
||||
} catch (error) {
|
||||
this.send('error', error);
|
||||
}
|
||||
@ -78,10 +77,15 @@ export default Controller.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
return yield this.store.query('invite', {limit: 'all'});
|
||||
}),
|
||||
// ensure roles are loaded before invites. Invites do not have embedded
|
||||
// role records which means Ember Data will try to fetch the roles
|
||||
// automatically when invite.role is queried, loading roles first makes
|
||||
// them available in memory and cuts down on network noise
|
||||
let knownRoles = this.store.peekAll('role');
|
||||
if (knownRoles.length <= 1) {
|
||||
yield this.store.query('role', {limit: 'all'});
|
||||
}
|
||||
|
||||
fetchRoles: task(function* () {
|
||||
return yield this.store.findAll('role');
|
||||
return yield this.store.query('invite', {limit: 'all'});
|
||||
})
|
||||
});
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint camelcase: [2, {properties: "never"}] */
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
import {belongsTo} from 'ember-data/relationships';
|
||||
@ -13,6 +12,7 @@ export default Model.extend({
|
||||
updatedAtUTC: attr('moment-utc'),
|
||||
updatedBy: attr('number'),
|
||||
status: attr('string'),
|
||||
|
||||
role: belongsTo('role', {async: false}),
|
||||
|
||||
ajax: service(),
|
||||
|
@ -2,7 +2,6 @@ import ApplicationSerializer from 'ghost-admin/serializers/application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
role: {key: 'role_id'},
|
||||
createdAtUTC: {key: 'created_at'},
|
||||
updatedAtUTC: {key: 'updated_at'}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user