DEV: Remove unnecessary setupController methods (#29592)

and call super instead of manually setting model
This commit is contained in:
Jarek Radosz 2024-11-05 13:17:32 +01:00 committed by GitHub
parent 54e7dee6d7
commit cbfd596b1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 12 additions and 48 deletions

View File

@ -18,8 +18,8 @@ export default class AdminCustomizeColorsShowRoute extends Route {
return { scheme_id: model.get("id") }; return { scheme_id: model.get("id") };
} }
setupController(controller, model) { setupController(controller) {
controller.set("model", model); super.setupController(...arguments);
controller.set("allColors", this.modelFor("adminCustomize.colors")); controller.set("allColors", this.modelFor("adminCustomize.colors"));
} }
} }

View File

@ -5,8 +5,4 @@ export default class AdminCustomizeColorsRoute extends Route {
model() { model() {
return ColorScheme.findAll(); return ColorScheme.findAll();
} }
setupController(controller, model) {
controller.set("model", model);
}
} }

View File

@ -5,8 +5,4 @@ export default class AdminCustomizeFormTemplatesEdit extends DiscourseRoute {
model(params) { model(params) {
return FormTemplate.findById(params.id); return FormTemplate.findById(params.id);
} }
setupController(controller, model) {
controller.set("model", model);
}
} }

View File

@ -7,10 +7,6 @@ export default class AdminCustomizeFormTemplatesIndex extends DiscourseRoute {
return FormTemplate.findAll(); return FormTemplate.findAll();
} }
setupController(controller, model) {
controller.set("model", model);
}
@action @action
reloadModel() { reloadModel() {
this.refresh(); this.refresh();

View File

@ -6,8 +6,8 @@ export default class AdminEmailIncomingsRoute extends DiscourseRoute {
return IncomingEmail.findAll({ status: this.status }); return IncomingEmail.findAll({ status: this.status });
} }
setupController(controller, model) { setupController(controller) {
controller.set("model", model); super.setupController(...arguments);
controller.set("filter.status", this.status); controller.set("filter.status", this.status);
} }
} }

View File

@ -5,8 +5,4 @@ export default class AdminPermalinksRoute extends DiscourseRoute {
model() { model() {
return Permalink.findAll(); return Permalink.findAll();
} }
setupController(controller, model) {
controller.set("model", model);
}
} }

View File

@ -8,7 +8,9 @@ export default class AdminUserBadgesRoute extends DiscourseRoute {
return UserBadge.findByUsername(username); return UserBadge.findByUsername(username);
} }
setupController(controller, model) { setupController(controller) {
super.setupController(...arguments);
// Find all badges. // Find all badges.
controller.set("loading", true); controller.set("loading", true);
Badge.findAll().then(function (badges) { Badge.findAll().then(function (badges) {
@ -21,7 +23,5 @@ export default class AdminUserBadgesRoute extends DiscourseRoute {
} }
controller.set("loading", false); controller.set("loading", false);
}); });
// Set the model.
controller.set("model", model);
} }
} }

View File

@ -57,8 +57,8 @@ export default class BadgesShow extends DiscourseRoute {
} }
} }
setupController(controller, model) { setupController(controller) {
controller.set("model", model); super.setupController(...arguments);
controller.set("userBadges", this.userBadgesGrant); controller.set("userBadges", this.userBadgesGrant);
controller.set("userBadgesAll", this.userBadgesAll); controller.set("userBadgesAll", this.userBadgesAll);
} }

View File

@ -12,8 +12,4 @@ export default class Group extends DiscourseRoute {
serialize(model) { serialize(model) {
return { name: model.get("name").toLowerCase() }; return { name: model.get("name").toLowerCase() };
} }
setupController(controller, model) {
controller.set("model", model);
}
} }

View File

@ -18,10 +18,6 @@ export default class GroupsNew extends DiscourseRoute {
}); });
} }
setupController(controller, model) {
controller.set("model", model);
}
afterModel() { afterModel() {
if (!this.get("currentUser.can_create_group")) { if (!this.get("currentUser.can_create_group")) {
this.router.transitionTo("groups"); this.router.transitionTo("groups");

View File

@ -28,8 +28,8 @@ export default class PasswordReset extends DiscourseRoute {
} }
} }
setupController(controller, model) { setupController(controller) {
controller.set("model", model); super.setupController(...arguments);
controller.initSelectedSecondFactorMethod(); controller.initSelectedSecondFactorMethod();
} }
} }

View File

@ -1,7 +1,3 @@
import RestrictedUserRoute from "discourse/routes/restricted-user"; import RestrictedUserRoute from "discourse/routes/restricted-user";
export default class PreferencesProfile extends RestrictedUserRoute { export default class PreferencesProfile extends RestrictedUserRoute {}
setupController(controller, model) {
controller.set("model", model);
}
}

View File

@ -4,8 +4,4 @@ export default class extends DiscourseRoute {
model() { model() {
return this.modelFor("user"); return this.modelFor("user");
} }
setupController(controller, model) {
controller.set("model", model);
}
} }

View File

@ -11,10 +11,6 @@ export default class UserPrivateMessages extends DiscourseRoute {
this.pmTopicTrackingState.startTracking(); this.pmTopicTrackingState.startTracking();
} }
setupController() {
super.setupController(...arguments);
}
@action @action
triggerRefresh() { triggerRefresh() {
this.refresh(); this.refresh();