Skip to content

Commit

Permalink
undo single function
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 committed Jul 7, 2024
1 parent 6ba0d0e commit 26d3d8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
24 changes: 14 additions & 10 deletions custom_components/mail_and_packages/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ async def async_step_reconfig_2(self, user_input=None):
return await self.async_step_reconfig_amazon()
if self._data[CONF_CUSTOM_IMG]:
return await self.async_step_reconfig_3()
await self._complete_reconfig_flow()

self.hass.config_entries.async_update_entry(self._entry, data=self._data)
await self.hass.config_entries.async_reload(self._entry.entry_id)
_LOGGER.debug("%s reconfigured.", DOMAIN)
return self.async_abort(reason="reconfigure_successful")

return await self._show_reconfig_2(user_input)

Expand All @@ -487,7 +491,10 @@ async def async_step_reconfig_3(self, user_input=None):
self._errors, user_input = await _validate_user_input(self._data)
self._data.update(user_input)
if len(self._errors) == 0:
await self._complete_reconfig_flow()
self.hass.config_entries.async_update_entry(self._entry, data=self._data)
await self.hass.config_entries.async_reload(self._entry.entry_id)
_LOGGER.debug("%s reconfigured.", DOMAIN)
return self.async_abort(reason="reconfigure_successful")

return await self._show_reconfig_3(user_input)

Expand Down Expand Up @@ -515,7 +522,11 @@ async def async_step_reconfig_amazon(self, user_input=None):
if len(self._errors) == 0:
if self._data[CONF_CUSTOM_IMG]:
return await self.async_step_reconfig_3()
await self._complete_reconfig_flow()

self.hass.config_entries.async_update_entry(self._entry, data=self._data)
await self.hass.config_entries.async_reload(self._entry.entry_id)
_LOGGER.debug("%s reconfigured.", DOMAIN)
return self.async_abort(reason="reconfigure_successful")

return await self._show_reconfig_amazon(user_input)

Expand All @@ -535,10 +546,3 @@ async def _show_reconfig_amazon(self, user_input):
data_schema=_get_schema_step_amazon(user_input, defaults),
errors=self._errors,
)

async def _complete_reconfig_flow(self):
"""Complete reconfigure flow."""
self.hass.config_entries.async_update_entry(self._entry, data=self._data)
await self.hass.config_entries.async_reload(self._entry.entry_id)
_LOGGER.debug("%s reconfigured.", DOMAIN)
return self.async_abort(reason="reconfigure_successful")
1 change: 1 addition & 0 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,5 +1709,6 @@ async def test_reconfigure(
assert result["reason"] == "reconfigure_successful"
await hass.async_block_till_done()

_LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN)))
entry = hass.config_entries.async_entries(DOMAIN)[0]
assert entry.data.copy() == data

0 comments on commit 26d3d8a

Please sign in to comment.