Skip to content

Commit

Permalink
Don't send category updates to queue (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Feb 6, 2022
1 parent d820b45 commit 867ee76
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/hacs/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ def _update(self) -> None:
async def async_added_to_hass(self) -> None:
"""Register for status events."""
self.async_on_remove(
self.hass.bus.async_listen("hacs/status", self._update_and_write_state)
self.hass.bus.async_listen("hacs/repository", self._update_and_write_state)
)
12 changes: 7 additions & 5 deletions custom_components/hacs/tasks/update_default_repositories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""""Hacs base setup task."""
from __future__ import annotations
import asyncio

from datetime import timedelta

Expand All @@ -26,11 +27,12 @@ async def async_execute(self) -> None:
"""Execute the task."""
self.hacs.log.info("Loading known repositories")

for category in self.hacs.common.categories or []:
self.hacs.queue.add(self.async_get_category_repositories(HacsCategory(category)))

if queue_task := self.hacs.tasks.get("prosess_queue"):
await queue_task.execute_task()
await asyncio.gather(
*[
self.async_get_category_repositories(HacsCategory(category))
for category in self.hacs.common.categories or []
]
)

async def async_get_category_repositories(self, category: HacsCategory) -> None:
"""Get repositories from category."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hacs/utils/default.repositories

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def test_sensor_update_event(hacs: HacsBase, hass: HomeAssistant):
hacs.common.categories = {"integration"}
assert sensor.state is None

hass.bus.async_fire("hacs/status", {})
hass.bus.async_fire("hacs/repository", {})

await hass.async_block_till_done()
assert sensor.state == 1
Expand Down

0 comments on commit 867ee76

Please sign in to comment.