Removes the ZapSplit display when the weights are zero or were incorrectly created.

This commit is contained in:
Vitor Pamplona 2023-09-18 10:36:05 -04:00
parent 4d1a99d076
commit 83be43e94e
3 changed files with 13 additions and 8 deletions

View File

@ -1076,6 +1076,8 @@ private fun NoteBody(
fun DisplayZapSplits(noteEvent: EventInterface, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
val list = remember(noteEvent) { noteEvent.zapSplitSetup() }
if (list.isEmpty()) return
Row(verticalAlignment = CenterVertically) {
Box(
Modifier

View File

@ -127,7 +127,6 @@ fun WatchAccountForVideoScreen(videoFeedView: NostrVideoFeedViewModel, accountVi
}
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun SaveableFeedState(
videoFeedView: NostrVideoFeedViewModel,

View File

@ -96,16 +96,20 @@ open class Event(
override fun hasZapSplitSetup() = tags.any { it.size > 1 && it[0] == "zap" }
override fun zapSplitSetup(): List<ZapSplitSetup> {
return tags.filter { it.size > 1 && it[0] == "zap" }.map {
return tags.filter { it.size > 1 && it[0] == "zap" }.mapNotNull {
val isLnAddress = it[0].contains("@") || it[0].startsWith("LNURL", true)
val weight = if (isLnAddress) 1.0 else (it.getOrNull(3)?.toDoubleOrNull() ?: 0.0)
ZapSplitSetup(
it[1],
it.getOrNull(2),
weight,
isLnAddress
)
if (weight > 0) {
ZapSplitSetup(
it[1],
it.getOrNull(2),
weight,
isLnAddress
)
} else {
null
}
}
}