Use read-only options in lastfm options flow (#129928)

Use read-only options in lstfm options flow
pull/129931/head
epenet 2024-11-06 08:14:54 +01:00 committed by GitHub
parent f88bc008e5
commit 184cbfea23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 6 deletions

View File

@ -163,24 +163,25 @@ class LastFmOptionsFlowHandler(OptionsFlow):
) -> ConfigFlowResult:
"""Initialize form."""
errors: dict[str, str] = {}
options = self.config_entry.options
if user_input is not None:
users, errors = validate_lastfm_users(
self.options[CONF_API_KEY], user_input[CONF_USERS]
options[CONF_API_KEY], user_input[CONF_USERS]
)
user_input[CONF_USERS] = users
if not errors:
return self.async_create_entry(
title="LastFM",
data={
**self.options,
**options,
CONF_USERS: user_input[CONF_USERS],
},
)
if self.options[CONF_MAIN_USER]:
if options[CONF_MAIN_USER]:
try:
main_user, _ = get_lastfm_user(
self.options[CONF_API_KEY],
self.options[CONF_MAIN_USER],
options[CONF_API_KEY],
options[CONF_MAIN_USER],
)
friends_response = await self.hass.async_add_executor_job(
main_user.get_friends
@ -206,6 +207,6 @@ class LastFmOptionsFlowHandler(OptionsFlow):
),
}
),
user_input or self.options,
user_input or options,
),
)