2020-03-31 23:09:07 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserBookmarkList
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
PER_PAGE = 20
|
|
|
|
|
2021-01-18 16:53:49 -06:00
|
|
|
attr_reader :bookmarks, :per_page
|
2020-03-31 23:09:07 -05:00
|
|
|
attr_accessor :more_bookmarks_url
|
|
|
|
|
2020-04-01 00:04:04 -05:00
|
|
|
def initialize(user:, guardian:, params:)
|
2020-03-31 23:09:07 -05:00
|
|
|
@user = user
|
|
|
|
@guardian = guardian
|
2021-01-18 16:53:49 -06:00
|
|
|
@params = params
|
|
|
|
|
|
|
|
@params.merge!(per_page: PER_PAGE) if params[:per_page].blank?
|
|
|
|
@params[:per_page] = PER_PAGE if @params[:per_page] > PER_PAGE
|
|
|
|
|
2020-03-31 23:09:07 -05:00
|
|
|
@bookmarks = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def load
|
|
|
|
@bookmarks = BookmarkQuery.new(user: @user, guardian: @guardian, params: @params).list_all
|
|
|
|
@bookmarks
|
|
|
|
end
|
|
|
|
|
|
|
|
def per_page
|
2021-01-18 16:53:49 -06:00
|
|
|
@per_page ||= @params[:per_page]
|
2020-03-31 23:09:07 -05:00
|
|
|
end
|
|
|
|
end
|