diff --git a/app/controllers/api/v0/users_controller.rb b/app/controllers/api/v0/users_controller.rb index 5aaea0eec..760a579c3 100644 --- a/app/controllers/api/v0/users_controller.rb +++ b/app/controllers/api/v0/users_controller.rb @@ -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 || diff --git a/app/javascript/sidebar-widget/SidebarWidget.jsx b/app/javascript/sidebar-widget/SidebarWidget.jsx index 03614797d..79a568a1c 100644 --- a/app/javascript/sidebar-widget/SidebarWidget.jsx +++ b/app/javascript/sidebar-widget/SidebarWidget.jsx @@ -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 }); diff --git a/app/views/api/v0/users/index.json.jbuilder b/app/views/api/v0/users/index.json.jbuilder index 717212f4b..451824719 100644 --- a/app/views/api/v0/users/index.json.jbuilder +++ b/app/views/api/v0/users/index.json.jbuilder @@ -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