Better rounding for zaps

This commit is contained in:
Vitor Pamplona
2024-06-11 11:30:55 -04:00
parent 9ca6151313
commit c71c87e946
@@ -475,17 +475,21 @@ open class NewPostViewModel() : ViewModel() {
val zapReceiver = val zapReceiver =
if (wantsForwardZapTo) { if (wantsForwardZapTo) {
forwardZapTo.items.map { split -> forwardZapTo.items.mapNotNull { split ->
val homeRelay = if (split.percentage > 0.00001) {
accountViewModel?.getRelayListFor(split.key)?.writeRelays()?.firstOrNull() val homeRelay =
?: split.key.relaysBeingUsed.keys.firstOrNull { !it.contains("localhost") } accountViewModel?.getRelayListFor(split.key)?.writeRelays()?.firstOrNull()
?: split.key.relaysBeingUsed.keys.firstOrNull { !it.contains("localhost") }
ZapSplitSetup( ZapSplitSetup(
lnAddressOrPubKeyHex = split.key.pubkeyHex, lnAddressOrPubKeyHex = split.key.pubkeyHex,
relay = homeRelay, relay = homeRelay,
weight = round(split.percentage.toDouble() * 10000), weight = round(split.percentage.toDouble() * 10000) / 10000,
isLnAddress = false, isLnAddress = false,
) )
} else {
null
}
} }
} else { } else {
null null