mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
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.
This commit is contained in:
@@ -85,7 +85,7 @@ class OkHttpArtworkFetcher(
|
|||||||
val request = Request.Builder().url(url).build()
|
val request = Request.Builder().url(url).build()
|
||||||
http.newCall(request).execute().use { response ->
|
http.newCall(request).execute().use { response ->
|
||||||
if (!response.isSuccessful) throw IOException("Artwork request failed with ${response.code}")
|
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")
|
if (body.contentLength() > maxBytes) throw IOException("Artwork response is larger than $maxBytes bytes")
|
||||||
val source = body.source()
|
val source = body.source()
|
||||||
source.request(maxBytes + 1)
|
source.request(maxBytes + 1)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import kotlinx.coroutines.CompletableDeferred
|
|||||||
import kotlinx.coroutines.CoroutineDispatcher
|
import kotlinx.coroutines.CoroutineDispatcher
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
@@ -157,6 +158,7 @@ class DownloadRepository(
|
|||||||
resumed.forEach { fetchArtworkSafely(it.sourceId, it.songId) }
|
resumed.forEach { fetchArtworkSafely(it.sourceId, it.songId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
private fun downloadStates(): Flow<Map<String, SongDownload>> =
|
private fun downloadStates(): Flow<Map<String, SongDownload>> =
|
||||||
sourceRepository
|
sourceRepository
|
||||||
.activeSourceId()
|
.activeSourceId()
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ fun HeroHeader(
|
|||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.heightIn(min = 32.dp)
|
.heightIn(min = 32.dp)
|
||||||
.clickable(onClickLabel = "Open artist") { onSubtitleClick?.invoke() },
|
.clickable(onClickLabel = "Open artist") { onSubtitleClick() },
|
||||||
contentAlignment = Alignment.TopCenter,
|
contentAlignment = Alignment.TopCenter,
|
||||||
) {
|
) {
|
||||||
HeroSubtitle(subtitle, Modifier.padding(top = 4.dp))
|
HeroSubtitle(subtitle, Modifier.padding(top = 4.dp))
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ class MediaItemTest {
|
|||||||
fun aDownloadedFileIsNotClippedEvenForATranscodingQuality() {
|
fun aDownloadedFileIsNotClippedEvenForATranscodingQuality() {
|
||||||
val item = queueMediaItem(song, local = "file:///downloads/1/s1", stream = "http://server/stream?s=s1", transcode = true)
|
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
|
@Test
|
||||||
fun aTranscodedStreamIsClippedToItsDeclaredDuration() {
|
fun aTranscodedStreamIsClippedToItsDeclaredDuration() {
|
||||||
val item = queueMediaItem(song, local = null, stream = "http://server/stream?s=s1", transcode = true)
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user