Skip to content

Commit

Permalink
DEV: Resolve routing method deprecation (#512)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
davidtaylorhq authored Oct 2, 2023
1 parent 93ee2cb commit df34e91
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/javascripts/discourse/routes/group-assigned.js
Original file line number Diff line number Diff line change
@@ -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}`);
}
Expand All @@ -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");
}
}
}

0 comments on commit df34e91

Please sign in to comment.