Closes #203: disable genre, year search types in Albums tab if API version < 1.10.1

This commit is contained in:
Sumner Evans
2020-07-12 11:12:44 -06:00
parent b3c63ce0e0
commit e7a293cb28
5 changed files with 23 additions and 24 deletions

View File

@@ -469,7 +469,6 @@ class Adapter(abc.ABC):
:returns: A set of :class:`AlbumSearchQuery.Type` objects.
"""
# TODO (#203): use this
return set()
@property

View File

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

View File

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

View File

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

View File

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