From df34e91b55d0d068bd983fd6a9fd7d3235cfc1fe Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 2 Oct 2023 15:10:31 +0100 Subject: [PATCH] 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) --- assets/javascripts/discourse/routes/group-assigned.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/routes/group-assigned.js b/assets/javascripts/discourse/routes/group-assigned.js index 56d1544..8ee6231 100644 --- a/assets/javascripts/discourse/routes/group-assigned.js +++ b/assets/javascripts/discourse/routes/group-assigned.js @@ -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"); } } }