diff --git a/api/funkwhale_api/music/filters.py b/api/funkwhale_api/music/filters.py index feae9b81c..79b2d2c63 100644 --- a/api/funkwhale_api/music/filters.py +++ b/api/funkwhale_api/music/filters.py @@ -1,3 +1,5 @@ +from django.db.models import Q + from django_filters import rest_framework as filters from funkwhale_api.audio import filters as audio_filters @@ -112,6 +114,9 @@ class TrackFilter( scope = common_filters.ActorScopeFilter( actor_field="uploads__library__actor", distinct=True ) + artist = filters.ModelChoiceFilter( + field_name="_", method="filter_artist", queryset=models.Artist.objects.all() + ) class Meta: model = models.Track @@ -119,7 +124,6 @@ class TrackFilter( "title": ["exact", "iexact", "startswith", "icontains"], "playable": ["exact"], "id": ["exact"], - "artist": ["exact"], "album": ["exact"], "license": ["exact"], "scope": ["exact"], @@ -134,6 +138,9 @@ class TrackFilter( actor = utils.get_actor_from_request(self.request) return queryset.playable_by(actor, value).distinct() + def filter_artist(self, queryset, name, value): + return queryset.filter(Q(artist=value) | Q(album__artist=value)) + class UploadFilter(audio_filters.IncludeChannelsFilterSet): library = filters.CharFilter("library__uuid") diff --git a/api/tests/music/test_filters.py b/api/tests/music/test_filters.py index 9bb8fd158..87d8c4816 100644 --- a/api/tests/music/test_filters.py +++ b/api/tests/music/test_filters.py @@ -184,3 +184,22 @@ def test_library_filter_artist(factories, queryset_equal_list, mocker, anonymous ) assert filterset.qs == [upload.track.artist] + + +def test_track_filter_artist_includes_album_artist( + factories, mocker, queryset_equal_list, anonymous_user +): + factories["music.Track"]() + track1 = factories["music.Track"]() + track2 = factories["music.Track"]( + album__artist=track1.artist, artist=factories["music.Artist"]() + ) + + qs = models.Track.objects.all() + filterset = filters.TrackFilter( + {"artist": track1.artist.pk}, + request=mocker.Mock(user=anonymous_user), + queryset=qs, + ) + + assert filterset.qs == [track2, track1] diff --git a/changes/changelog.d/1078.bugfix b/changes/changelog.d/1078.bugfix new file mode 100644 index 000000000..fc966e9bd --- /dev/null +++ b/changes/changelog.d/1078.bugfix @@ -0,0 +1 @@ +Include tracks by album artist when filtering by artist on /api/v1/tracks (#1078) diff --git a/changes/changelog.d/1092.bugfix b/changes/changelog.d/1092.bugfix new file mode 100644 index 000000000..018470ac8 --- /dev/null +++ b/changes/changelog.d/1092.bugfix @@ -0,0 +1 @@ +Ensure player doesn't disappear when last queue track is removed manually (#1092) diff --git a/docs/users/followchannel.rst b/docs/users/followchannel.rst index c235bdfc7..e664a1c19 100644 --- a/docs/users/followchannel.rst +++ b/docs/users/followchannel.rst @@ -20,7 +20,7 @@ If you have the channel's full social network name: URL to the channel - Click "Subscribe" -Following Funwkhale Channels Through the Fediverse +Following Funkwhale Channels Through the Fediverse -------------------------------------------------- Funkwhale channels can be followed from different ActivityPub-enabled applications diff --git a/front/src/store/queue.js b/front/src/store/queue.js index 5514db921..a5ab856a4 100644 --- a/front/src/store/queue.js +++ b/front/src/store/queue.js @@ -104,8 +104,13 @@ export default { commit('splice', {start: index, size: 1}) if (index < state.currentIndex) { commit('currentIndex', state.currentIndex - 1) - } - if (current) { + } else if (index > 0 && index === state.tracks.length) { + // kind of a edge case: if you delete the last track of the queue + // we set current index to the previous one to avoid the queue tab from + // being stuck because the player disappeared + // cf #1092 + commit('currentIndex', state.tracks.length - 1) + } else if (current) { // we play next track, which now have the same index commit('currentIndex', index) } diff --git a/front/tests/unit/specs/store/queue.spec.js b/front/tests/unit/specs/store/queue.spec.js index afdf46c90..f69098246 100644 --- a/front/tests/unit/specs/store/queue.spec.js +++ b/front/tests/unit/specs/store/queue.spec.js @@ -133,7 +133,7 @@ describe('store/queue', () => { testAction({ action: store.actions.cleanTrack, payload: 3, - params: {state: {currentIndex: 2, tracks: []}}, + params: {state: {currentIndex: 2, tracks: [1, 2, 3, 4, 5]}}, expectedMutations: [ { type: 'splice', payload: {start: 3, size: 1} } ]