Fixed error where playlist artwork would continually be in a loading state if refresh failed
This commit is contained in:
@@ -372,8 +372,8 @@ class AdapterManager:
|
|||||||
fn = getattr(AdapterManager._instance.ground_truth_adapter, function_name)
|
fn = getattr(AdapterManager._instance.ground_truth_adapter, function_name)
|
||||||
try:
|
try:
|
||||||
return fn(*params, **kwargs)
|
return fn(*params, **kwargs)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
raise CacheMissError(partial_data=partial_data)
|
raise CacheMissError(partial_data=partial_data) from e
|
||||||
|
|
||||||
return Result(future_fn)
|
return Result(future_fn)
|
||||||
|
|
||||||
|
@@ -354,7 +354,6 @@ class SubsonicAdapter(Adapter):
|
|||||||
self,
|
self,
|
||||||
url: str,
|
url: str,
|
||||||
timeout: Union[float, Tuple[float, float], None] = None,
|
timeout: Union[float, Tuple[float, float], None] = None,
|
||||||
# TODO (#122): retry count
|
|
||||||
is_exponential_backoff_ping: bool = False,
|
is_exponential_backoff_ping: bool = False,
|
||||||
**params,
|
**params,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
@@ -390,7 +389,6 @@ class SubsonicAdapter(Adapter):
|
|||||||
url, params=params, verify=self.verify_cert, timeout=timeout,
|
url, params=params, verify=self.verify_cert, timeout=timeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO (#122): make better
|
|
||||||
if result.status_code != 200:
|
if result.status_code != 200:
|
||||||
raise ServerError(
|
raise ServerError(
|
||||||
result.status_code, f"{url} returned status={result.status_code}."
|
result.status_code, f"{url} returned status={result.status_code}."
|
||||||
@@ -433,7 +431,6 @@ class SubsonicAdapter(Adapter):
|
|||||||
)
|
)
|
||||||
subsonic_response = result.json().get("subsonic-response")
|
subsonic_response = result.json().get("subsonic-response")
|
||||||
|
|
||||||
# TODO (#122): make better
|
|
||||||
if not subsonic_response:
|
if not subsonic_response:
|
||||||
raise ServerError(500, f"{url} returned invalid JSON.")
|
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:
|
def get_playlist_details(self, playlist_id: str) -> API.Playlist:
|
||||||
result = self._get_json(self._make_url("getPlaylist"), id=playlist_id).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}"
|
assert result, f"Error getting playlist {playlist_id}"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@@ -525,7 +525,7 @@ class PlaylistDetailPanel(Gtk.Overlay):
|
|||||||
@util.async_callback(
|
@util.async_callback(
|
||||||
AdapterManager.get_playlist_details,
|
AdapterManager.get_playlist_details,
|
||||||
before_download=lambda self: self.show_loading_all(),
|
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(
|
def update_playlist_view(
|
||||||
self,
|
self,
|
||||||
@@ -894,6 +894,10 @@ class PlaylistDetailPanel(Gtk.Overlay):
|
|||||||
self.playlist_artwork.set_loading(True)
|
self.playlist_artwork.set_loading(True)
|
||||||
self.playlist_view_loading_box.show_all()
|
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:
|
def make_label(self, text: str = None, name: str = None, **params,) -> Gtk.Label:
|
||||||
return Gtk.Label(
|
return Gtk.Label(
|
||||||
label=text,
|
label=text,
|
||||||
|
Reference in New Issue
Block a user