Use `InboxFilter` in `Moderation::InboxController`

This commit is contained in:
Andreas Nedbal 2024-01-27 20:15:13 +01:00 committed by Andreas Nedbal
parent 62ba205d3e
commit d12e3b020e
1 changed files with 10 additions and 2 deletions

View File

@ -5,9 +5,11 @@ class Moderation::InboxController < ApplicationController
def index
@user = User.find_by(screen_name: params[:user])
@inboxes = @user.cursored_inbox(last_id: params[:last_id])
filter = InboxFilter.new(@user, filter_params)
@inboxes = filter.cursored_results(last_id: params[:last_id])
@inbox_last_id = @inboxes.map(&:id).min
@more_data_available = !@user.cursored_inbox(last_id: @inbox_last_id, size: 1).count.zero?
@more_data_available = !filter.cursored_results(last_id: @inbox_last_id, size: 1).count.zero?
@inbox_count = @user.inbox_entries.count
respond_to do |format|
@ -15,4 +17,10 @@ class Moderation::InboxController < ApplicationController
format.turbo_stream { render "index", layout: false, status: :see_other }
end
end
private
def filter_params
params.slice(*InboxFilter::KEYS).permit(*InboxFilter::KEYS)
end
end