mirror of
https://ghfast.top/https://github.com/discourse/discourse-follow.git
synced 2026-07-16 11:46:25 +08:00
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".
22 lines
653 B
JavaScript
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");
|
|
}
|
|
}
|
|
}
|