Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 12, 2024
1 parent 26f9a12 commit 57a5878
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,15 @@ def set_loading(self, loading: bool) -> Awaitable:
An optional awaitable.
"""
LOADING_INDICATOR_CLASS = "-textual-loading-indicator"
LOADING_INDICATOR_QUERY = f".{LOADING_INDICATOR_CLASS}"
remove_indicator = self.query_children(LOADING_INDICATOR_QUERY).remove()
if loading:
remove_indicator = self.query_children(
f".{LOADING_INDICATOR_CLASS}"
).remove()
loading_indicator = self.get_loading_widget()
loading_indicator.add_class(LOADING_INDICATOR_CLASS)
await_mount = self.mount(loading_indicator)
return AwaitComplete(remove_indicator, await_mount)
else:
return self.query_children(f".{LOADING_INDICATOR_CLASS}").remove()
return remove_indicator

async def _watch_loading(self, loading: bool) -> None:
"""Called when the 'loading' reactive is changed."""
Expand Down

0 comments on commit 57a5878

Please sign in to comment.