From cc6b91ba037f17472d90c2fa38899c44f5c36aae Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Wed, 5 Mar 2025 15:18:28 -0800 Subject: [PATCH] Updated UI and renamed attribute --- lib/pinchflat/sources/source.ex | 3 +-- .../controllers/sources/source_html.ex | 8 ++++++++ .../sources/source_html/source_form.html.heex | 13 +++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/pinchflat/sources/source.ex b/lib/pinchflat/sources/source.ex index aa4966a..00b4776 100644 --- a/lib/pinchflat/sources/source.ex +++ b/lib/pinchflat/sources/source.ex @@ -78,8 +78,7 @@ defmodule Pinchflat.Sources.Source do field :collection_type, Ecto.Enum, values: [:channel, :playlist] field :index_frequency_minutes, :integer, default: 60 * 24 field :fast_index, :boolean, default: false - # TODO: consider renaming `indexing_only` to something like `when_needed` (but better) - field :cookie_behaviour, Ecto.Enum, values: [:disabled, :indexing_only, :all_operations], default: :disabled + field :cookie_behaviour, Ecto.Enum, values: [:disabled, :when_needed, :all_operations], default: :disabled field :download_media, :boolean, default: true field :last_indexed_at, :utc_datetime # Only download media items that were published after this date diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index 57a57b4..00ab498 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -27,6 +27,14 @@ defmodule PinchflatWeb.Sources.SourceHTML do ] end + def friendly_cookie_behaviours do + [ + {"Disabled", :disabled}, + {"When Needed", :when_needed}, + {"All Operations", :all_operations} + ] + end + def cutoff_date_presets do [ {"7 days", compute_date_offset(7)}, diff --git a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex index d4e41f2..94b4110 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex @@ -86,12 +86,13 @@ help="Unchecking still indexes media but it won't be downloaded until you enable this option" /> - <.input - field={f[:use_cookies]} - type="toggle" - label="Use Cookies for Downloading" - help="Uses your YouTube cookies for this source (if configured). Used for downloading private playlists and videos. See docs for important details" - /> + <.input + field={f[:cookie_behaviour]} + options={friendly_cookie_behaviours()} + type="select" + label="Cookie Behaviour" + help="Uses your YouTube cookies for this source (if configured). 'When Needed' tries to minimize cookie usage except for certain indexing and downloading tasks. See docs" + />
<.input