library: keep the artist screen fast and avoid placeholder labels

Rewrite the artist album lookup as indexed UNION branches instead of ORs
that scanned the song table, and let artistName take the first indexed row.

Keep the type label and album count blank until the album flow has emitted,
so the page no longer flashes "Artist" and "0 albums" before showing the
real values.
This commit is contained in:
austinried
2026-10-18 02:35:55 +00:00
parent 61a2472ea9
commit 6c3028eeb2
5 changed files with 78 additions and 21 deletions
@@ -91,6 +91,8 @@ class QueryTimingMeasurementTest {
timed("albums first page (recent)") { dao.albumsByRecent(1, 0, "").firstPage() }
timed("artists first page (name)") { dao.artistsByName(1, 0, "").firstPage() }
timed("artists first page (frequent)") { dao.artistsByFrequent(1, 0, "").firstPage() }
timed("artist albums") { dao.albumsForArtist(1, "ar0").first() }
timed("artist name") { dao.artistName(1, "ar0").first() }
timed("playlists first page (name)") { dao.playlistsByName(1, "").firstPage() }
timed("albums deep page") { dao.albumsByName(1, 0, "").deepPage(1000) }
timed("albums search FTS") { dao.albumsByName(1, 0, "Album 1").firstPage() }
@@ -24,7 +24,8 @@ class ArtistDetailScreenTest {
private fun render(
artist: Artist?,
artistName: String,
isAlbumArtist: Boolean,
isAlbumArtist: Boolean? = null,
albumsLoaded: Boolean = true,
) {
composeRule.setContent {
SubtracksTheme {
@@ -33,6 +34,7 @@ class ArtistDetailScreenTest {
artistName = artistName,
isAlbumArtist = isAlbumArtist,
albums = emptyList(),
albumsLoaded = albumsLoaded,
art = null,
coverArt = { _, _ -> null },
onBack = {},
@@ -62,4 +64,17 @@ class ArtistDetailScreenTest {
composeRule.onNodeWithText("Album artist").assertExists()
composeRule.onNodeWithContentDescription("More options").assertExists()
}
@Test
fun theTypeAndCountStayBlankUntilTheAlbumsLoad() {
render(
artist = Artist(sourceId = 1, id = "ar-1", name = "Radiohead", albumCount = 1, starred = null),
artistName = "Radiohead",
albumsLoaded = false,
)
composeRule.onNodeWithText("Artist").assertDoesNotExist()
composeRule.onNodeWithText("Album artist").assertDoesNotExist()
composeRule.onNodeWithText("0 albums").assertDoesNotExist()
}
}