From 71bea9a00f715d72293f24ba45ef75ebb1ece80a Mon Sep 17 00:00:00 2001 From: Aniket Tuli Date: Wed, 13 May 2026 11:26:17 -0700 Subject: [PATCH] fix: localize stream label at render, simplify parser test runBlocking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StreamItem.streamLabel now returns name.orEmpty() so the data class stays locale-neutral. The four composable display sites (StreamsScreen, PlayerSourcesPanel, PlayerEpisodesPanel, PlayerControls) localize the blank case with stringResource(Res.string.stream_default_name). DownloadsRepository's fallbackTitle path is unchanged because buildFileName already does .ifBlank { "download" }; DownloadItem.streamTitle is only re-read in PlayerScreen which already has its own .ifBlank fallback. Also drops the redundant outer runBlocking wrapper on the assertFailsWith test in MetaDetailsParserTest — only the inner runBlocking is needed since assertFailsWith's lambda is non-suspend. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../kotlin/com/nuvio/app/features/player/PlayerControls.kt | 2 +- .../com/nuvio/app/features/player/PlayerEpisodesPanel.kt | 2 +- .../com/nuvio/app/features/player/PlayerSourcesPanel.kt | 2 +- .../kotlin/com/nuvio/app/features/streams/StreamModels.kt | 2 +- .../kotlin/com/nuvio/app/features/streams/StreamsScreen.kt | 4 ++-- .../com/nuvio/app/features/details/MetaDetailsParserTest.kt | 3 +-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerControls.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerControls.kt index 13f975ed..70008d3a 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerControls.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerControls.kt @@ -238,7 +238,7 @@ private fun PlayerHeader( verticalAlignment = Alignment.CenterVertically, ) { Text( - text = streamTitle, + text = streamTitle.ifBlank { stringResource(Res.string.stream_default_name) }, style = typeScale.labelSm.copy( fontSize = metrics.metadataSize, lineHeight = metrics.metadataSize * 1.25f, diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerEpisodesPanel.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerEpisodesPanel.kt index 69eb462e..734c3eca 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerEpisodesPanel.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerEpisodesPanel.kt @@ -629,7 +629,7 @@ private fun EpisodeSourceStreamRow( ) { Column(modifier = Modifier.weight(1f)) { Text( - text = stream.streamLabel, + text = stream.streamLabel.ifBlank { stringResource(Res.string.stream_default_name) }, color = colorScheme.onSurface, fontSize = 14.sp, fontWeight = FontWeight.Medium, diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerSourcesPanel.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerSourcesPanel.kt index 9e64a911..252f938d 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerSourcesPanel.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerSourcesPanel.kt @@ -267,7 +267,7 @@ private fun SourceStreamRow( horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Text( - text = stream.streamLabel, + text = stream.streamLabel.ifBlank { stringResource(Res.string.stream_default_name) }, color = colorScheme.onSurface, style = MaterialTheme.typography.bodyMedium.copy( fontSize = 14.sp, diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamModels.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamModels.kt index fc097eed..f58022ab 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamModels.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamModels.kt @@ -13,7 +13,7 @@ data class StreamItem( val behaviorHints: StreamBehaviorHints = StreamBehaviorHints(), ) { val streamLabel: String - get() = name ?: "Stream" + get() = name.orEmpty() val streamSubtitle: String? get() = description diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt index 68eeca73..4fc5d9c4 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt @@ -994,7 +994,7 @@ private fun StreamCard( ) { Column(modifier = Modifier.weight(1f)) { Text( - text = stream.streamLabel, + text = stream.streamLabel.ifBlank { stringResource(Res.string.stream_default_name) }, style = MaterialTheme.typography.bodyMedium.copy( fontSize = 14.sp, fontWeight = FontWeight.Bold, @@ -1060,7 +1060,7 @@ private fun StreamActionsSheet( verticalArrangement = Arrangement.spacedBy(4.dp), ) { Text( - text = stream.streamLabel, + text = stream.streamLabel.ifBlank { stringResource(Res.string.stream_default_name) }, style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onSurface, fontWeight = FontWeight.SemiBold, diff --git a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/details/MetaDetailsParserTest.kt b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/details/MetaDetailsParserTest.kt index db3cc461..5cfdeefd 100644 --- a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/details/MetaDetailsParserTest.kt +++ b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/details/MetaDetailsParserTest.kt @@ -8,11 +8,10 @@ import kotlin.test.assertFailsWith class MetaDetailsParserTest { @Test - fun `parse rejects null meta object without json object cast crash`() = runBlocking { + fun `parse rejects null meta object without json object cast crash`() { assertFailsWith { runBlocking { MetaDetailsParser.parse("""{"meta":null}""") } } - Unit } @Test