discourse/app/assets/javascripts/admin/routes/admin-users-list-show.js.es6
Joffrey JAFFEUX 71360436ff
FIX: users list show was loading multiple times with different params (#7058)
A first load was happening in route, which was setting properties on controller. These properties were observed on the controller and were triggering a reload of the AdminUser model.

Not only was it doing loading two times it was also sometimes resulting on the controller model refresh end to happen after route has been changed, resulting in a wrong model.
2019-02-26 10:43:24 +01:00

29 lines
838 B
JavaScript

export default Discourse.Route.extend({
queryParams: {
order: { refreshModel: true },
ascending: { refreshModel: true }
},
// TODO: this has been introduced to fix a bug in admin-users-list-show
// loading AdminUser model multiple times without refactoring the controller
beforeModel(transition) {
const routeName = "adminUsersList.show";
if (transition.targetName === routeName) {
const params = transition.params[routeName];
const controller = this.controllerFor(routeName);
if (controller) {
controller.setProperties({
order: transition.queryParams.order,
ascending: transition.queryParams.ascending,
query: params.filter,
showEmails: false,
refreshing: false
});
controller._refreshUsers();
}
}
}
});