mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix issue registry sending unneeded update events (#98230)
This commit is contained in:
parent
b653d7f683
commit
296c27859e
@ -154,7 +154,7 @@ class IssueRegistry:
|
|||||||
{"action": "create", "domain": domain, "issue_id": issue_id},
|
{"action": "create", "domain": domain, "issue_id": issue_id},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
issue = self.issues[(domain, issue_id)] = dataclasses.replace(
|
replacement = dataclasses.replace(
|
||||||
issue,
|
issue,
|
||||||
active=True,
|
active=True,
|
||||||
breaks_in_ha_version=breaks_in_ha_version,
|
breaks_in_ha_version=breaks_in_ha_version,
|
||||||
@ -167,10 +167,14 @@ class IssueRegistry:
|
|||||||
translation_key=translation_key,
|
translation_key=translation_key,
|
||||||
translation_placeholders=translation_placeholders,
|
translation_placeholders=translation_placeholders,
|
||||||
)
|
)
|
||||||
self.hass.bus.async_fire(
|
# Only fire is something changed
|
||||||
EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED,
|
if replacement != issue:
|
||||||
{"action": "update", "domain": domain, "issue_id": issue_id},
|
issue = self.issues[(domain, issue_id)] = replacement
|
||||||
)
|
self.async_schedule_save()
|
||||||
|
self.hass.bus.async_fire(
|
||||||
|
EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED,
|
||||||
|
{"action": "update", "domain": domain, "issue_id": issue_id},
|
||||||
|
)
|
||||||
|
|
||||||
return issue
|
return issue
|
||||||
|
|
||||||
|
@ -109,11 +109,51 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||||||
"issue_id": "issue_1",
|
"issue_id": "issue_1",
|
||||||
}
|
}
|
||||||
|
|
||||||
ir.async_delete_issue(hass, issues[2]["domain"], issues[2]["issue_id"])
|
# Update an issue by creating it again with the same value,
|
||||||
|
# no update event should be fired, as nothing changed.
|
||||||
|
ir.async_create_issue(
|
||||||
|
hass,
|
||||||
|
issues[2]["domain"],
|
||||||
|
issues[2]["issue_id"],
|
||||||
|
breaks_in_ha_version=issues[2]["breaks_in_ha_version"],
|
||||||
|
is_fixable=issues[2]["is_fixable"],
|
||||||
|
is_persistent=issues[2]["is_persistent"],
|
||||||
|
learn_more_url=issues[2]["learn_more_url"],
|
||||||
|
severity=issues[2]["severity"],
|
||||||
|
translation_key=issues[2]["translation_key"],
|
||||||
|
translation_placeholders=issues[2]["translation_placeholders"],
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert len(events) == 5
|
||||||
|
|
||||||
|
# Update an issue by creating it again, url changed
|
||||||
|
ir.async_create_issue(
|
||||||
|
hass,
|
||||||
|
issues[2]["domain"],
|
||||||
|
issues[2]["issue_id"],
|
||||||
|
breaks_in_ha_version=issues[2]["breaks_in_ha_version"],
|
||||||
|
is_fixable=issues[2]["is_fixable"],
|
||||||
|
is_persistent=issues[2]["is_persistent"],
|
||||||
|
learn_more_url="https://www.example.com/something_changed",
|
||||||
|
severity=issues[2]["severity"],
|
||||||
|
translation_key=issues[2]["translation_key"],
|
||||||
|
translation_placeholders=issues[2]["translation_placeholders"],
|
||||||
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(events) == 6
|
assert len(events) == 6
|
||||||
assert events[5].data == {
|
assert events[5].data == {
|
||||||
|
"action": "update",
|
||||||
|
"domain": "test",
|
||||||
|
"issue_id": "issue_3",
|
||||||
|
}
|
||||||
|
|
||||||
|
ir.async_delete_issue(hass, issues[2]["domain"], issues[2]["issue_id"])
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert len(events) == 7
|
||||||
|
assert events[6].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"domain": "test",
|
"domain": "test",
|
||||||
"issue_id": "issue_3",
|
"issue_id": "issue_3",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user