DEV: Resolve routing method deprecation (#512)

Uses the router service for redirecting instead of `this.transitionTo`. Also removes the first branch of logic, which was unnecessarily redirecting to the current route (and led to an infinite loop with the modern API)
This commit is contained in:
David Taylor 2023-10-02 15:10:31 +01:00 committed by GitHub
parent 93ee2cb886
commit df34e91b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax";
import { inject as service } from "@ember/service";
export default class GroupAssigned extends DiscourseRoute {
@service router;
model() {
return ajax(`/assign/members/${this.modelFor("group").name}`);
}
@ -21,10 +24,8 @@ export default class GroupAssigned extends DiscourseRoute {
}
redirect(model, transition) {
if (transition.to.params.hasOwnProperty("filter")) {
this.transitionTo("group.assigned.show", transition.to.params.filter);
} else {
this.transitionTo("group.assigned.show", "everyone");
if (!transition.to.params.hasOwnProperty("filter")) {
this.router.transitionTo("group.assigned.show", "everyone");
}
}
}