class BroadcastRecordingStarringsController < ApplicationController
  layout "project"

  before_action :set_project
  before_action :set_broadcast
  before_action :set_recording

  def create
    @recording.toggle_star
    set_recordings
  end

  private

  def broadcast_recording_params
    params.require(:broadcast_recording).permit(:name, :description)
  end

  def set_project
    @project = policy_scope(Project).find(params[:project_id])
  end

  def set_broadcast
    @broadcast = authorize policy_scope(@project.broadcasts).find(params[:broadcast_id])
  end

  def set_recording
    @recording = authorize policy_scope(@broadcast.broadcast_recordings).find(params[:broadcast_recording_id])
  end

  def set_recordings
    @recordings = @broadcast.broadcast_recordings.visible.order_by_recent.paginate(page: params[:page])
  end
end
