mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
ui: cover the artist section split in tests
Assert the combined meta line while loading, cover the downloaded partition and the plural album/song credit branches, share the album-credit id query with its plan test, and put the meta line through a translatable string.
This commit is contained in:
@@ -118,6 +118,10 @@ internal const val ALBUMS_FOR_ARTIST =
|
||||
"JOIN albums ON albums.sourceId = :sourceId AND albums.id = credits.albumId " +
|
||||
"ORDER BY year DESC, sortName COLLATE NOCASE, id"
|
||||
|
||||
internal const val ALBUM_CREDIT_ALBUM_IDS =
|
||||
"SELECT DISTINCT albumId FROM ($CREDITED_ALBUM_ROWS) " +
|
||||
"WHERE artistId = :artistId AND albumCredit = 1"
|
||||
|
||||
// Download visibility follows the credit path: an album credit includes the album when any song is
|
||||
// downloaded, while a track credit includes it only when the credited track is downloaded.
|
||||
private const val DOWNLOADED_ARTIST_ALBUMS =
|
||||
@@ -1066,10 +1070,7 @@ interface LibraryDao {
|
||||
artistId: String,
|
||||
): Flow<List<Album>>
|
||||
|
||||
@Query(
|
||||
"SELECT DISTINCT albumId FROM ($CREDITED_ALBUM_ROWS) " +
|
||||
"WHERE artistId = :artistId AND albumCredit = 1",
|
||||
)
|
||||
@Query(ALBUM_CREDIT_ALBUM_IDS)
|
||||
fun albumCreditAlbumIds(
|
||||
sourceId: Long,
|
||||
artistId: String,
|
||||
|
||||
@@ -387,10 +387,8 @@ class LibraryRepository(
|
||||
}
|
||||
return combine(albums, db.libraryDao().albumCreditAlbumIds(sourceId, artistId)) { list, creditIds ->
|
||||
val credits = creditIds.toHashSet()
|
||||
ArtistAlbums(
|
||||
albumCredits = list.filter { it.id in credits },
|
||||
appearances = list.filterNot { it.id in credits },
|
||||
)
|
||||
val (albumCredits, appearances) = list.partition { it.id in credits }
|
||||
ArtistAlbums(albumCredits = albumCredits, appearances = appearances)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,13 +252,8 @@ fun ArtistDetailScreen(
|
||||
stringResource(
|
||||
if (albums.albumCredits.isNotEmpty()) R.string.artist_type_album_artist else R.string.artist_type_artist,
|
||||
)
|
||||
val albumCountText =
|
||||
if (albumsLoaded) {
|
||||
pluralStringResource(R.plurals.resources_album_count, albumCount.toInt(), albumCount)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val metaText = if (albumsLoaded) "$artistType · $albumCountText" else ""
|
||||
val albumCountText = pluralStringResource(R.plurals.resources_album_count, albumCount.toInt(), albumCount)
|
||||
val metaText = if (albumsLoaded) stringResource(R.string.artist_meta, artistType, albumCountText) else ""
|
||||
var titleHeightPx by remember { mutableFloatStateOf(0f) }
|
||||
val titleHeight = if (titleHeightPx > 0f) with(density) { titleHeightPx.toDp() } else lineHeight
|
||||
val titleMaxLines =
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<string name="artist_type_album_artist">Album artist</string>
|
||||
<string name="artist_section_albums">Albums (%1$d)</string>
|
||||
<string name="artist_section_appearances">Appears on (%1$d)</string>
|
||||
<string name="artist_meta">%1$s · %2$s</string>
|
||||
<string name="resources_filter_genre">Genre</string>
|
||||
<string name="resources_filter_starred">Starred</string>
|
||||
<string name="resources_song_list_delete_all_content">%1$s\n\nDeleting will free %2$s</string>
|
||||
|
||||
Reference in New Issue
Block a user