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

View file

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