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,9 +43,16 @@ class DirectoryItemsController < ApplicationController
|
||||||
more_params[:page] = page + 1
|
more_params[:page] = page + 1
|
||||||
|
|
||||||
# Put yourself at the top of the first page
|
# 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
|
||||||
your_item = DirectoryItem.where(period_type: period_type, user_id: current_user.id).first
|
|
||||||
result.insert(0, your_item) if your_item
|
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
|
end
|
||||||
|
|
||||||
render_json_dump(directory_items: serialize_data(result, DirectoryItemSerializer),
|
render_json_dump(directory_items: serialize_data(result, DirectoryItemSerializer),
|
||||||
|
|
Loading…
Reference in New Issue