From d710a3185cbd1b8b43e429db5a5797216ad863c4 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sun, 27 Sep 2026 09:57:48 +0000 Subject: [PATCH] clear the compile warnings the downloads work left behind - ArtworkStore's fetcher still did `response.body ?: throw` from before the body size limit landed; OkHttp's `body` is not nullable, so the elvis was dead. - DownloadRepository's `downloadStates` uses `flatMapLatest` without the opt-in its callers annotate. - HeroHeader's subtitle tap invoked `onSubtitleClick?.invoke()` inside the branch where it is already known to be non-null. - MediaItemTest used a safe call on `clippingConfiguration`, which never returns null. No behaviour change: a clean full rebuild now compiles without warnings. --- .../main/kotlin/com/subtracks/data/download/ArtworkStore.kt | 2 +- .../main/kotlin/com/subtracks/data/repo/DownloadRepository.kt | 2 ++ .../kotlin/com/subtracks/ui/components/HeroDetailScaffold.kt | 2 +- app/src/test/kotlin/com/subtracks/playback/MediaItemTest.kt | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/data/download/ArtworkStore.kt b/app/src/main/kotlin/com/subtracks/data/download/ArtworkStore.kt index 560e0da2..b3b542b3 100644 --- a/app/src/main/kotlin/com/subtracks/data/download/ArtworkStore.kt +++ b/app/src/main/kotlin/com/subtracks/data/download/ArtworkStore.kt @@ -85,7 +85,7 @@ class OkHttpArtworkFetcher( val request = Request.Builder().url(url).build() http.newCall(request).execute().use { response -> if (!response.isSuccessful) throw IOException("Artwork request failed with ${response.code}") - val body = response.body ?: throw IOException("Artwork response had no body") + val body = response.body if (body.contentLength() > maxBytes) throw IOException("Artwork response is larger than $maxBytes bytes") val source = body.source() source.request(maxBytes + 1) diff --git a/app/src/main/kotlin/com/subtracks/data/repo/DownloadRepository.kt b/app/src/main/kotlin/com/subtracks/data/repo/DownloadRepository.kt index 8e66f4e1..5c28c697 100644 --- a/app/src/main/kotlin/com/subtracks/data/repo/DownloadRepository.kt +++ b/app/src/main/kotlin/com/subtracks/data/repo/DownloadRepository.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel @@ -157,6 +158,7 @@ class DownloadRepository( resumed.forEach { fetchArtworkSafely(it.sourceId, it.songId) } } + @OptIn(ExperimentalCoroutinesApi::class) private fun downloadStates(): Flow> = sourceRepository .activeSourceId() diff --git a/app/src/main/kotlin/com/subtracks/ui/components/HeroDetailScaffold.kt b/app/src/main/kotlin/com/subtracks/ui/components/HeroDetailScaffold.kt index 7cbe6e24..2e961041 100644 --- a/app/src/main/kotlin/com/subtracks/ui/components/HeroDetailScaffold.kt +++ b/app/src/main/kotlin/com/subtracks/ui/components/HeroDetailScaffold.kt @@ -253,7 +253,7 @@ fun HeroHeader( modifier = Modifier .heightIn(min = 32.dp) - .clickable(onClickLabel = "Open artist") { onSubtitleClick?.invoke() }, + .clickable(onClickLabel = "Open artist") { onSubtitleClick() }, contentAlignment = Alignment.TopCenter, ) { HeroSubtitle(subtitle, Modifier.padding(top = 4.dp)) diff --git a/app/src/test/kotlin/com/subtracks/playback/MediaItemTest.kt b/app/src/test/kotlin/com/subtracks/playback/MediaItemTest.kt index adaa0959..585e059f 100644 --- a/app/src/test/kotlin/com/subtracks/playback/MediaItemTest.kt +++ b/app/src/test/kotlin/com/subtracks/playback/MediaItemTest.kt @@ -36,14 +36,14 @@ class MediaItemTest { fun aDownloadedFileIsNotClippedEvenForATranscodingQuality() { val item = queueMediaItem(song, local = "file:///downloads/1/s1", stream = "http://server/stream?s=s1", transcode = true) - assertEquals(C.TIME_END_OF_SOURCE, item.clippingConfiguration?.endPositionMs) + assertEquals(C.TIME_END_OF_SOURCE, item.clippingConfiguration.endPositionMs) } @Test fun aTranscodedStreamIsClippedToItsDeclaredDuration() { val item = queueMediaItem(song, local = null, stream = "http://server/stream?s=s1", transcode = true) - assertEquals(100_000L, item.clippingConfiguration?.endPositionMs) + assertEquals(100_000L, item.clippingConfiguration.endPositionMs) } @Test