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
@@ -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
}
}
}