2016-02-12 23:52:43 +08:00
|
|
|
class ActivitiesController < ApplicationController
|
2017-01-12 21:47:15 +08:00
|
|
|
include ActivityHelper
|
|
|
|
|
2016-02-12 23:52:43 +08:00
|
|
|
def index
|
2018-03-12 18:01:23 +08:00
|
|
|
@vars = local_vars
|
2023-06-21 20:13:20 +08:00
|
|
|
render json: {
|
|
|
|
more_url: local_vars.fetch(:more_activities_url),
|
|
|
|
html: render_to_string(
|
2023-07-05 18:43:23 +08:00
|
|
|
partial: 'list', locals: @vars, formats: :html
|
2023-06-21 20:13:20 +08:00
|
|
|
)
|
|
|
|
}
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
2018-01-03 20:48:59 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def local_vars
|
|
|
|
page = (params[:page] || 1).to_i
|
|
|
|
activities = current_user.last_activities
|
|
|
|
.page(page)
|
|
|
|
.per(Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
|
2018-08-20 20:26:42 +08:00
|
|
|
unless activities.blank? || activities.last_page?
|
2018-01-06 00:08:00 +08:00
|
|
|
more_url = url_for(
|
|
|
|
activities_url(
|
|
|
|
format: :json,
|
|
|
|
page: page + 1,
|
|
|
|
last_activity: activities.last.id
|
|
|
|
)
|
|
|
|
)
|
2018-01-03 20:48:59 +08:00
|
|
|
end
|
|
|
|
{
|
|
|
|
activities: activities,
|
|
|
|
more_activities_url: more_url,
|
2018-11-14 20:17:38 +08:00
|
|
|
page: page
|
2018-01-03 20:48:59 +08:00
|
|
|
}
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|