Skip to content

Commit

Permalink
Fix missing notification when browsing already completed directory
Browse files Browse the repository at this point in the history
Refs: #57
  • Loading branch information
orontee committed Jan 15, 2023
1 parent 1abdb5b commit 780c525
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions argos/controllers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,15 @@ async def browse_directory(self, message: Message) -> None:
default_uri = self._model.library.props.default_uri
directory_uri = message.data.get("uri", default_uri)
force = message.data.get("force", False)
asyncio.create_task(self._browse_directory(directory_uri, force=force))

async def browse_and_notify() -> None:
await self._browse_directory(directory_uri, force=force)
GLib.idle_add(self._model.emit, "directory-completed", directory_uri)

# note that GLib event loop will update model THEN emit the
# directory-completed signal

asyncio.create_task(browse_and_notify())

async def _browse_directory(
self,
Expand Down Expand Up @@ -250,9 +258,6 @@ async def _browse_directory(
tracks=tracks,
wait_for_model_update=wait_for_model_update,
)
GLib.idle_add(self._model.emit, "directory-completed", directory_uri)
# note that GLib event loop will update model THEN emit the
# directory-completed signal

async def _complete_albums(
self,
Expand Down

0 comments on commit 780c525

Please sign in to comment.