mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 07:21:58 +00:00
fix: localize stream label at render, simplify parser test runBlocking
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) <noreply@anthropic.com>
This commit is contained in:
parent
62d38f74f8
commit
71bea9a00f
6 changed files with 7 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<IllegalStateException> {
|
||||
runBlocking { MetaDetailsParser.parse("""{"meta":null}""") }
|
||||
}
|
||||
Unit
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue