diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-23 01:40:26 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-23 01:40:26 +0300 |
commit | 99682502119fa67f229b3e8d3c3ed0ccb68b29f9 (patch) | |
tree | 9c59486c0d6ea7d1fbdd93300e22cebaa8b367d2 /app/controllers/users_controller.rb | |
parent | 29f6b01d6343c08dc9fe1f6bdf95a645dd4e4cc0 (diff) |
Add inifinite scroll to user activity on user page
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r-- | app/controllers/users_controller.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 68130eb128c..95ee9e83dbd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -16,17 +16,16 @@ class UsersController < ApplicationController # Collect only groups common for both users @groups = @user.groups & GroupsFinder.new.execute(current_user) - # Get user activity feed for projects common for both users - @events = @user.recent_events. - where(project_id: authorized_projects_ids). - with_associations.limit(30) - @title = @user.name @title_url = user_path(@user) respond_to do |format| format.html format.atom { render layout: false } + format.json do + load_events + pager_json("events/_events", @events.count) + end end end @@ -82,4 +81,13 @@ class UsersController < ApplicationController @authorized_projects_ids ||= ProjectsFinder.new.execute(current_user).pluck(:id) end + + def load_events + # Get user activity feed for projects common for both users + @events = @user.recent_events. + where(project_id: authorized_projects_ids). + with_associations + + @events = @events.limit(20).offset(params[:offset] || 0) + end end |