mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05: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
1 changed files with 3 additions and 7 deletions
|
@ -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) {
|
||||
// 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…
Add table
Reference in a new issue