Explicitly set auto-refresh config for LastFm refresh

This commit is contained in:
Claudio Ortolina
2024-12-03 19:58:17 +00:00
parent f58a5e83b7
commit 61cda5a62c
4 changed files with 5 additions and 8 deletions
+2 -5
View File
@@ -3,19 +3,16 @@ defmodule LastFm.Config do
api: module(),
api_key: String.t(),
user: String.t(),
auto_refresh: boolean(),
refresh_interval: pos_integer()
}
defstruct api: LastFm.Api,
api_key: "",
user: "",
auto_refresh: true,
refresh_interval: 60_000
@spec enabled?(t) :: boolean()
def enabled?(config) do
config.api && config.user !== "" && config.api_key !== ""
end
@spec resolve(atom) :: t
def resolve(otp_app) do
app_config =
+1 -1
View File
@@ -20,7 +20,7 @@ defmodule LastFm.Refresh do
@impl true
@spec init(config) :: {:ok, config, {:continue, :refresh}} | :ignore
def init(config) do
if Config.enabled?(config) do
if config.auto_refresh do
{:ok, config, {:continue, :refresh}}
else
:ignore