From b96b009555f023ea611bdda3630217e1f242ba34 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Sun, 2 Aug 2020 11:15:21 -0600 Subject: [PATCH] Fixed error where playlist artwork would continually be in a loading state if refresh failed --- sublime/adapters/manager.py | 4 ++-- sublime/adapters/subsonic/adapter.py | 4 ---- sublime/ui/playlists.py | 6 +++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sublime/adapters/manager.py b/sublime/adapters/manager.py index 375b198..6ec196a 100644 --- a/sublime/adapters/manager.py +++ b/sublime/adapters/manager.py @@ -372,8 +372,8 @@ class AdapterManager: fn = getattr(AdapterManager._instance.ground_truth_adapter, function_name) try: return fn(*params, **kwargs) - except Exception: - raise CacheMissError(partial_data=partial_data) + except Exception as e: + raise CacheMissError(partial_data=partial_data) from e return Result(future_fn) diff --git a/sublime/adapters/subsonic/adapter.py b/sublime/adapters/subsonic/adapter.py index de7133a..b348726 100644 --- a/sublime/adapters/subsonic/adapter.py +++ b/sublime/adapters/subsonic/adapter.py @@ -354,7 +354,6 @@ class SubsonicAdapter(Adapter): self, url: str, timeout: Union[float, Tuple[float, float], None] = None, - # TODO (#122): retry count is_exponential_backoff_ping: bool = False, **params, ) -> Any: @@ -390,7 +389,6 @@ class SubsonicAdapter(Adapter): url, params=params, verify=self.verify_cert, timeout=timeout, ) - # TODO (#122): make better if result.status_code != 200: raise ServerError( result.status_code, f"{url} returned status={result.status_code}." @@ -433,7 +431,6 @@ class SubsonicAdapter(Adapter): ) subsonic_response = result.json().get("subsonic-response") - # TODO (#122): make better if not subsonic_response: raise ServerError(500, f"{url} returned invalid JSON.") @@ -487,7 +484,6 @@ class SubsonicAdapter(Adapter): def get_playlist_details(self, playlist_id: str) -> API.Playlist: result = self._get_json(self._make_url("getPlaylist"), id=playlist_id).playlist - # TODO (#122) better error (here and elsewhere) assert result, f"Error getting playlist {playlist_id}" return result diff --git a/sublime/ui/playlists.py b/sublime/ui/playlists.py index af13bff..ef811f9 100644 --- a/sublime/ui/playlists.py +++ b/sublime/ui/playlists.py @@ -525,7 +525,7 @@ class PlaylistDetailPanel(Gtk.Overlay): @util.async_callback( AdapterManager.get_playlist_details, before_download=lambda self: self.show_loading_all(), - on_failure=lambda self, e: self.playlist_view_loading_box.hide(), + on_failure=lambda self, e: self.hide_loading_all(), ) def update_playlist_view( self, @@ -894,6 +894,10 @@ class PlaylistDetailPanel(Gtk.Overlay): self.playlist_artwork.set_loading(True) self.playlist_view_loading_box.show_all() + def hide_loading_all(self): + self.playlist_artwork.set_loading(False) + self.playlist_view_loading_box.hide() + def make_label(self, text: str = None, name: str = None, **params,) -> Gtk.Label: return Gtk.Label( label=text,