mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
Fixed Ember Data error when navigating to Staff screen
no issue - if only some roles have been loaded, such as from embedded user records in posts, navigating to the Staff screen when invites exist for roles that have not yet been loaded would result in an Ember Data error - the error occurs because we use `invite.role.*` in the template but we've specified `{async: false}` in the `belongsTo` relationship for `invite.role` which prevents Ember Data automatically querying the API - by always fetching the roles list before fetching the invites list we prevent the error but we do introduce an extra API request in some circumstances
This commit is contained in:
parent
a862cb6b6a
commit
190f2e905d
@ -78,13 +78,9 @@ export default Controller.extend({
|
||||
}
|
||||
|
||||
// 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'});
|
||||
}
|
||||
// role records which means Ember Data will throw errors when trying to
|
||||
// read the invite.role data when the role has not yet been loaded
|
||||
yield this.store.query('role', {limit: 'all'});
|
||||
|
||||
return yield this.store.query('invite', {limit: 'all'});
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user