Skip to content

Fix: Prevent crash in SearchScreen due to duplicate genre keys#238

Merged
theovilardo merged 1 commit intomasterfrom
fix-genre-crash
Oct 11, 2025
Merged

Fix: Prevent crash in SearchScreen due to duplicate genre keys#238
theovilardo merged 1 commit intomasterfrom
fix-genre-crash

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

The SearchScreen was crashing when the list of music genres contained duplicates, as this resulted in non-unique keys being passed to the LazyVerticalGrid.

This commit fixes the issue by ensuring the genre list is always unique. In PlayerViewModel, the genres StateFlow now uses .distinctBy { it.id } to filter out any genres that have the same ID. This guarantees that the UI receives a list with unique keys, preventing the crash.

The SearchScreen was crashing when the list of music genres contained duplicates, as this resulted in non-unique keys being passed to the `LazyVerticalGrid`.

This commit fixes the issue by ensuring the genre list is always unique. In `PlayerViewModel`, the `genres` `StateFlow` now uses `.distinctBy { it.id }` to filter out any genres that have the same ID. This guarantees that the UI receives a list with unique keys, preventing the crash.
@theovilardo theovilardo merged commit 548675c into master Oct 11, 2025
@theovilardo theovilardo deleted the fix-genre-crash branch October 16, 2025 18:04
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.

1 participant