Fix shuffling artist & center top songs

This commit is contained in:
Damontecres 2026-03-21 17:13:04 -04:00
parent 64c6e4db79
commit 12e1c6f0c4
No known key found for this signature in database
2 changed files with 71 additions and 65 deletions

View file

@ -178,7 +178,7 @@ class ArtistViewModel
viewModelScope.launchIO { viewModelScope.launchIO {
val request = val request =
GetItemsRequest( GetItemsRequest(
parentId = itemId, artistIds = listOf(itemId),
fields = DefaultItemFields, fields = DefaultItemFields,
recursive = true, recursive = true,
includeItemTypes = listOf(BaseItemKind.AUDIO), includeItemTypes = listOf(BaseItemKind.AUDIO),
@ -382,7 +382,9 @@ fun ArtistDetailsPage(
actions = actions =
remember { remember {
MusicButtonActions( MusicButtonActions(
onClickPlay = { viewModel.play(artist) }, onClickPlay = { shuffled ->
viewModel.play(artist, shuffled = shuffled)
},
onClickInstantMix = { viewModel.startInstantMix(artist.id) }, onClickInstantMix = { viewModel.startInstantMix(artist.id) },
onClickFavorite = { onClickFavorite = {
viewModel.setFavorite( viewModel.setFavorite(
@ -437,68 +439,72 @@ fun ArtistDetailsPage(
) )
} }
itemsIndexed(state.topSongs) { index, song -> itemsIndexed(state.topSongs) { index, song ->
SongListItem( Box(
song = song, modifier = Modifier.fillMaxWidth(),
onClick = { contentAlignment = Alignment.Center,
position = RowColumn(SONG_ROW, index) ) {
song?.let { viewModel.play(it) } SongListItem(
}, song = song,
onLongClick = { onClick = {
if (song != null) { position = RowColumn(SONG_ROW, index)
moreDialog = song?.let { viewModel.play(it) }
DialogParams( },
fromLongClick = true, onLongClick = {
title = song.name ?: "", if (song != null) {
items = moreDialog =
buildMoreDialogForMusic( DialogParams(
context = context, fromLongClick = true,
actions = moreDialogActions, title = song.name ?: "",
item = song, items =
index = index, buildMoreDialogForMusic(
canRemove = false, context = context,
canDelete = actions = moreDialogActions,
viewModel.canDelete( item = song,
song, index = index,
preferences.appPreferences, canRemove = false,
), canDelete =
), viewModel.canDelete(
) song,
} preferences.appPreferences,
}, ),
onClickMore = { ),
if (song != null) { )
moreDialog = }
DialogParams( },
fromLongClick = false, onClickMore = {
title = song.name ?: "", if (song != null) {
items = moreDialog =
buildMoreDialogForMusic( DialogParams(
context = context, fromLongClick = false,
actions = moreDialogActions, title = song.name ?: "",
item = song, items =
index = index, buildMoreDialogForMusic(
canRemove = false, context = context,
canDelete = actions = moreDialogActions,
viewModel.canDelete( item = song,
song, index = index,
preferences.appPreferences, canRemove = false,
), canDelete =
), viewModel.canDelete(
) song,
} preferences.appPreferences,
}, ),
showArtist = false, ),
isPlaying = song != null && currentMusic.currentItemId == song.id, )
isQueued = song != null && song.id in currentMusic.queuedIds, }
modifier = },
Modifier showArtist = false,
.align(Alignment.Center) isPlaying = song != null && currentMusic.currentItemId == song.id,
.fillMaxWidth(.75f) isQueued = song != null && song.id in currentMusic.queuedIds,
.ifElse( modifier =
position.row == SONG_ROW && position.column == index, Modifier
Modifier.focusRequester(songFocusRequester), .fillMaxWidth(.75f)
), .ifElse(
) position.row == SONG_ROW && position.column == index,
Modifier.focusRequester(songFocusRequester),
),
)
}
} }
} }
item { item {

View file

@ -235,7 +235,7 @@ suspend fun ViewModel.getPagerForArtist(
): ApiRequestPager<GetItemsRequest> { ): ApiRequestPager<GetItemsRequest> {
val request = val request =
GetItemsRequest( GetItemsRequest(
parentId = artistId, artistIds = listOf(artistId),
recursive = true, recursive = true,
includeItemTypes = listOf(BaseItemKind.AUDIO), includeItemTypes = listOf(BaseItemKind.AUDIO),
fields = DefaultItemFields, fields = DefaultItemFields,