Closes #203: disable genre, year search types in Albums tab if API version < 1.10.1
This commit is contained in:
@@ -469,7 +469,6 @@ class Adapter(abc.ABC):
|
||||
|
||||
:returns: A set of :class:`AlbumSearchQuery.Type` objects.
|
||||
"""
|
||||
# TODO (#203): use this
|
||||
return set()
|
||||
|
||||
@property
|
||||
|
@@ -136,7 +136,6 @@ class FilesystemAdapter(CachingAdapter):
|
||||
return self._can_get_key(KEYS.GENRES)
|
||||
|
||||
supported_schemes = ("file",)
|
||||
# TODO (#203)
|
||||
supported_artist_query_types = {
|
||||
AlbumSearchQuery.Type.RANDOM,
|
||||
AlbumSearchQuery.Type.NEWEST,
|
||||
|
@@ -553,19 +553,10 @@ class AdapterManager:
|
||||
@staticmethod
|
||||
def get_supported_artist_query_types() -> Set[AlbumSearchQuery.Type]:
|
||||
assert AdapterManager._instance
|
||||
|
||||
supported_artist_query_types: Set[AlbumSearchQuery.Type] = set()
|
||||
supported_artist_query_types.union(
|
||||
return (
|
||||
AdapterManager._instance.ground_truth_adapter.supported_artist_query_types
|
||||
)
|
||||
|
||||
if caching_adapter := AdapterManager._instance.caching_adapter:
|
||||
supported_artist_query_types.union(
|
||||
caching_adapter.supported_artist_query_types
|
||||
)
|
||||
|
||||
return supported_artist_query_types
|
||||
|
||||
R = TypeVar("R")
|
||||
|
||||
@staticmethod
|
||||
|
@@ -313,18 +313,22 @@ class SubsonicAdapter(Adapter):
|
||||
self._schemes = (urlparse(self.hostname)[0],)
|
||||
return self._schemes
|
||||
|
||||
# TODO (#203) make this way smarter
|
||||
supported_artist_query_types = {
|
||||
AlbumSearchQuery.Type.RANDOM,
|
||||
AlbumSearchQuery.Type.NEWEST,
|
||||
AlbumSearchQuery.Type.FREQUENT,
|
||||
AlbumSearchQuery.Type.RECENT,
|
||||
AlbumSearchQuery.Type.STARRED,
|
||||
AlbumSearchQuery.Type.ALPHABETICAL_BY_NAME,
|
||||
AlbumSearchQuery.Type.ALPHABETICAL_BY_ARTIST,
|
||||
AlbumSearchQuery.Type.YEAR_RANGE,
|
||||
AlbumSearchQuery.Type.GENRE,
|
||||
}
|
||||
@property
|
||||
def supported_artist_query_types(self) -> Set[AlbumSearchQuery.Type]:
|
||||
supported = {
|
||||
AlbumSearchQuery.Type.RANDOM,
|
||||
AlbumSearchQuery.Type.NEWEST,
|
||||
AlbumSearchQuery.Type.FREQUENT,
|
||||
AlbumSearchQuery.Type.RECENT,
|
||||
AlbumSearchQuery.Type.STARRED,
|
||||
AlbumSearchQuery.Type.ALPHABETICAL_BY_NAME,
|
||||
AlbumSearchQuery.Type.ALPHABETICAL_BY_ARTIST,
|
||||
}
|
||||
if self.version_at_least("1.10.1"):
|
||||
supported.add(AlbumSearchQuery.Type.YEAR_RANGE)
|
||||
supported.add(AlbumSearchQuery.Type.GENRE)
|
||||
|
||||
return supported
|
||||
|
||||
# Helper mothods for making requests
|
||||
# ==================================================================================
|
||||
|
@@ -230,6 +230,12 @@ class AlbumsPanel(Gtk.Box):
|
||||
def update(self, app_config: AppConfiguration = None, force: bool = False):
|
||||
self.updating_query = True
|
||||
|
||||
supported_type_strings = {
|
||||
_to_type(t) for t in AdapterManager.get_supported_artist_query_types()
|
||||
}
|
||||
for i, el in enumerate(self.sort_type_combo_store):
|
||||
self.sort_type_combo_store[i][2] = el[0] in supported_type_strings
|
||||
|
||||
# (En|Dis)able getting genres.
|
||||
self.sort_type_combo_store[1][2] = AdapterManager.can_get_genres()
|
||||
|
||||
|
Reference in New Issue
Block a user