Move suggestions to single route
This commit is contained in:
parent
d2c68e9755
commit
71254cebb7
3 changed files with 13 additions and 13 deletions
|
|
@ -9,15 +9,12 @@ module Api
|
|||
end
|
||||
if params[:state] == "follow_suggestions"
|
||||
@users = UserFollowSuggester.new(current_user).suggestions
|
||||
elsif params[:state] == "sidebar_suggestions"
|
||||
given_tag = params[:tag]
|
||||
@users = UserFollowSuggester.new(current_user).sidebar_suggestions(given_tag)
|
||||
end
|
||||
end
|
||||
|
||||
def sidebar_suggestions
|
||||
given_tag = params[:tag]
|
||||
@users = UserFollowSuggester.new(nil).sidebar_suggestions(given_tag)
|
||||
render "index.json.jbuilder"
|
||||
end
|
||||
|
||||
def less_than_one_day_old?(user)
|
||||
range = (Time.now.beginning_of_day - 1.day)..(Time.now)
|
||||
user_identity_age = user.github_created_at ||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,16 @@ class SidebarWidget extends Component {
|
|||
}
|
||||
|
||||
getSuggestedUsers() {
|
||||
fetch(`/api/users/sidebar_suggestions?tag=${this.state.tagInfo.name}`, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
fetch(
|
||||
`/api/users?state=sidebar_suggestions&tag=${this.state.tagInfo.name}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
)
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
this.setState({ suggestedUsers: json });
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ json.array! @users.each do |user|
|
|||
json.name user.name
|
||||
json.username user.username
|
||||
json.profile_image_url ProfileImage.new(user).get(90)
|
||||
json.following current_user ? current_user.following?(user) : false
|
||||
json.following false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue