parent
b534249a8d
commit
f3a12ddfd0
2 changed files with 61 additions and 21 deletions
|
@ -15,19 +15,17 @@ class Api::V1::MutesController < Api::BaseController
|
|||
private
|
||||
|
||||
def load_accounts
|
||||
default_accounts.merge(paginated_mutes).to_a
|
||||
end
|
||||
|
||||
def default_accounts
|
||||
Account.includes(:muted_by).references(:muted_by)
|
||||
paginated_mutes.map(&:target_account)
|
||||
end
|
||||
|
||||
def paginated_mutes
|
||||
Mute.where(account: current_account).paginate_by_max_id(
|
||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||
params[:max_id],
|
||||
params[:since_id]
|
||||
)
|
||||
@paginated_mutes ||= Mute.eager_load(:target_account)
|
||||
.where(account: current_account)
|
||||
.paginate_by_max_id(
|
||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||
params[:max_id],
|
||||
params[:since_id]
|
||||
)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
@ -41,21 +39,21 @@ class Api::V1::MutesController < Api::BaseController
|
|||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
unless paginated_mutes.empty?
|
||||
api_v1_mutes_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
@accounts.last.muted_by_ids.last
|
||||
paginated_mutes.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
@accounts.first.muted_by_ids.first
|
||||
paginated_mutes.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||
paginated_mutes.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue