UX: Login to decide when to show you near the top of the directory
Don't show yourself there if you are close to the top already.
This commit is contained in:
parent
1ec73b5ba0
commit
82124b3222
|
@ -43,11 +43,18 @@ class DirectoryItemsController < ApplicationController
|
|||
more_params[:page] = page + 1
|
||||
|
||||
# Put yourself at the top of the first page
|
||||
if result.present? && current_user.present? && page == 0 && result[0].user_id != current_user.id
|
||||
if result.present? && current_user.present? && page == 0
|
||||
|
||||
position = result.index {|r| r.user_id == current_user.id }
|
||||
|
||||
# Don't show the record unless you're not in the top positions already
|
||||
if (position || 10) >= 10
|
||||
your_item = DirectoryItem.where(period_type: period_type, user_id: current_user.id).first
|
||||
result.insert(0, your_item) if your_item
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render_json_dump(directory_items: serialize_data(result, DirectoryItemSerializer),
|
||||
total_rows_directory_items: result_count,
|
||||
load_more_directory_items: directory_items_path(more_params))
|
||||
|
|
Loading…
Reference in New Issue