For #21626 - Avoid showing story invalid properties

upstream-sync
Mugurell 3 years ago committed by mergify[bot]
parent 2b363b9868
commit 361673ae3e

@ -46,6 +46,7 @@ import org.mozilla.fenix.compose.ListItemTabLarge
import org.mozilla.fenix.compose.ListItemTabLargePlaceholder
import org.mozilla.fenix.compose.SelectableChip
import org.mozilla.fenix.compose.StaggeredHorizontalGrid
import org.mozilla.fenix.compose.TabSubtitle
import org.mozilla.fenix.compose.TabSubtitleWithInterdot
import org.mozilla.fenix.compose.TabTitle
import org.mozilla.fenix.theme.FirefoxTheme
@ -76,6 +77,8 @@ fun PocketStory(
"{wh}",
with(LocalDensity.current) { "${116.dp.toPx().roundToInt()}x${84.dp.toPx().roundToInt()}" }
)
val isValidPublisher = story.publisher.isNotBlank()
val isValidTimeToRead = story.timeToRead >= 0
ListItemTabLarge(
client = client,
imageUrl = imageUrl,
@ -84,7 +87,13 @@ fun PocketStory(
TabTitle(text = story.title, maxLines = 3)
},
subtitle = {
TabSubtitleWithInterdot(story.publisher, "${story.timeToRead} min")
if (isValidPublisher && isValidTimeToRead) {
TabSubtitleWithInterdot(story.publisher, "${story.timeToRead} min")
} else if (isValidPublisher) {
TabSubtitle(story.publisher)
} else if (isValidTimeToRead) {
TabSubtitle("${story.timeToRead} min")
}
}
)
}

Loading…
Cancel
Save