Fixed error where playlist artwork would continually be in a loading state if refresh failed

This commit is contained in:
Sumner Evans
2020-08-02 11:15:21 -06:00
parent 8475089850
commit b96b009555
3 changed files with 7 additions and 7 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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,