Skip to content

feat: add genre filter for songs and albums - #1060

Draft
huynhsontung wants to merge 9 commits into
mainfrom
filter_music_by_genre
Draft

feat: add genre filter for songs and albums#1060
huynhsontung wants to merge 9 commits into
mainfrom
filter_music_by_genre

Conversation

@huynhsontung

Copy link
Copy Markdown
Owner

Resolves #698

Context

Users with large music collections need a way to filter songs and albums by genre directly in the library views. Unlike static sorting options, genres vary depending on the files present in the user's library and must be dynamically extracted.

Motivation

Providing a genre dropdown alongside the existing sort-by controls enables users to quickly narrow down their library views by specific music genres, view tracks with missing genre metadata ("Unknown genre"), or view all items ("All genres").

Impact & Changes

  • Library Models & Services:
    • MusicLibrary: Added read-only Genres property to the immutable music library snapshot.
    • LibraryService: Added ExtractGenres to automatically extract, deduplicate, and sort unique non-empty genre strings from library songs when building MusicLibrary snapshots.
  • ViewModels:
    • SongsPageViewModel & AlbumsPageViewModel: Added SelectedGenre, Genres, and SetGenreCommand. Filter Songs and GroupedSongs / GroupedAlbums dynamically based on selected genre.
  • UI & Performance:
    • Added GenreButton dropdown next to SortByButton in SongsPage.xaml and AlbumsPage.xaml.
    • Populated RadioMenuFlyoutItem elements as soon as the genre list is available (during page navigation and library updates) to ensure instantaneous flyout opening.
    • Preserved SelectedGenre state across backward navigation.
  • Localization & Accessibility:
    • Added ReswPlus resources for AllGenres, FilterByGenreAutomationName, and access key CommandFilterByGenreKey.
  • Tests:
    • Added unit test coverage for genre extraction, filtering, and commands in SongsPageViewModelTests and AlbumsPageViewModelTests.

huynhsontung and others added 8 commits August 19, 2026 14:05
Remember and restore the user's last selected sort order on SongsPage and AlbumsPage across app navigations and restarts.

- Add PersistentSongsSortBy and PersistentAlbumsSortBy properties to ISettingsService and SettingsService.
- Inject ISettingsService into SongsPageViewModel and AlbumsPageViewModel to initialize and persist sort order selections.
- Synchronize visual state and flyout radio item check state in SongsPage and AlbumsPage on navigation.
- Safely handle ApplicationLanguages.PrimaryLanguageOverride in MediaGroupingHelpers for unpackaged test environments.
- Add unit tests in Screenbox.Core.Tests covering sort order initialization and persistence.
…nce persistence

Replace string-based sort orders with strongly-typed SongSortOrder and AlbumSortOrder enums across settings, viewmodels, views, and unit tests.
…in SettingsService

Retain 'Persistent...' naming convention for sort order properties in ISettingsService and SettingsService.
…scing workarounds

Create DispatcherQueueTestHelper and global TestInitializer hook to enable DispatcherQueue and DispatcherQueueSynchronizationContext during test execution. Simplify SongsPageViewModel and AlbumsPageViewModel to use non-nullable DispatcherQueue and DispatcherQueueTimer directly.
…sPage and AlbumsPage

Use compiled {x:Bind IsSortBy(ViewModel.SortBy, ...)} on RadioMenuFlyoutItem.IsChecked to guarantee the active sort item is always selected when restoring from settings or navigating between pages.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ewModel and AlbumsPageViewModel

Add PumpEvents to DispatcherQueueTestHelper to process enqueued DispatcherQueue callbacks during tests. Update SongsPageViewModelTests and AlbumsPageViewModelTests to verify that Receive enqueues and executes FetchSongs/FetchAlbums by asserting that GroupedSongs and GroupedAlbums are populated with updated library data.
Remove Win32 message pump P/Invokes from DispatcherQueueTestHelper. Test vm.Receive directly and verify side-effects via vm.FetchSongs and vm.FetchAlbums.
@huynhsontung
huynhsontung changed the base branch from main to implement_persistent_sort_preference August 20, 2026 05:13
@huynhsontung huynhsontung changed the title feat(music): add genre filter for songs and albums feat: add genre filter for songs and albums Aug 20, 2026
@huynhsontung
huynhsontung force-pushed the filter_music_by_genre branch from e0e2dc5 to 9ca043d Compare August 20, 2026 07:26
Add dynamic genre filtering to songs and albums views. Genres are extracted from the user music library and exposed with 'All genres', 'Unknown genre', and library genres.
@huynhsontung
huynhsontung force-pushed the filter_music_by_genre branch from 9ca043d to 455b62d Compare August 20, 2026 07:27
Base automatically changed from implement_persistent_sort_preference to main August 24, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show music by Genre?

1 participant