discourse-follow/assets/javascripts/discourse/routes/follow/index.js
Régis Hanol 6c6c3a6ddc
DEV: Fix deprecated route resolver normalization (#165)
Moves follow-index.js to follow/index.js and adds empty follow.js route
to follow modern Ember resolver conventions. The old naming pattern 
"route:follow-index" is deprecated in favor of "route:follow/index".
2025-12-16 17:39:16 +01:00

22 lines
653 B
JavaScript

import { service } from "@ember/service";
import DiscourseRoute from "discourse/routes/discourse";
export default class FollowIndexRoute extends DiscourseRoute {
@service router;
beforeModel() {
const model = this.modelFor("user");
const canSeeFollowers = model.can_see_followers;
const canSeeFollowing = model.can_see_following;
if (this.currentUser?.id === model.id) {
this.router.replaceWith("feed");
} else if (canSeeFollowing) {
this.router.replaceWith("following");
} else if (canSeeFollowers) {
this.router.replaceWith("followers");
} else {
this.router.replaceWith("user");
}
}
}