mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 01:47:05 +02:00
- Adds the NIP-65 relay to zap
split tag instead of kind3 relays.
- Rounds percentages to the 2 decimals.
This commit is contained in:
@@ -79,6 +79,7 @@ import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.UUID
|
||||
import kotlin.math.round
|
||||
|
||||
enum class UserSuggestionAnchor {
|
||||
MAIN_MESSAGE,
|
||||
@@ -474,11 +475,15 @@ open class NewPostViewModel() : ViewModel() {
|
||||
|
||||
val zapReceiver =
|
||||
if (wantsForwardZapTo) {
|
||||
forwardZapTo.items.map {
|
||||
forwardZapTo.items.map { split ->
|
||||
val homeRelay =
|
||||
accountViewModel?.getRelayListFor(split.key)?.writeRelays()?.firstOrNull()
|
||||
?: split.key.relaysBeingUsed.keys.firstOrNull { !it.contains("localhost") }
|
||||
|
||||
ZapSplitSetup(
|
||||
lnAddressOrPubKeyHex = it.key.pubkeyHex,
|
||||
relay = it.key.relaysBeingUsed.keys.firstOrNull(),
|
||||
weight = it.percentage.toDouble(),
|
||||
lnAddressOrPubKeyHex = split.key.pubkeyHex,
|
||||
relay = homeRelay,
|
||||
weight = round(split.percentage.toDouble() * 10000),
|
||||
isLnAddress = false,
|
||||
)
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import androidx.compose.runtime.setValue
|
||||
import kotlin.math.abs
|
||||
|
||||
class SplitItem<T>(val key: T) {
|
||||
// 0 to 1
|
||||
var percentage by mutableStateOf(0f)
|
||||
}
|
||||
|
||||
|
@@ -74,6 +74,7 @@ import com.vitorpamplona.quartz.encoders.Nip11RelayInformation
|
||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.events.AddressableEvent
|
||||
import com.vitorpamplona.quartz.events.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.events.ChatMessageRelayListEvent
|
||||
import com.vitorpamplona.quartz.events.ChatroomKey
|
||||
import com.vitorpamplona.quartz.events.ChatroomKeyable
|
||||
@@ -1403,6 +1404,16 @@ class AccountViewModel(val account: Account, val settings: SettingsState) : View
|
||||
}
|
||||
}
|
||||
|
||||
fun getRelayListFor(user: User): AdvertisedRelayListEvent? {
|
||||
return (getRelayListNoteFor(user)?.event as? AdvertisedRelayListEvent?)
|
||||
}
|
||||
|
||||
fun getRelayListNoteFor(user: User): AddressableNote? {
|
||||
return LocalCache.getAddressableNoteIfExists(
|
||||
AdvertisedRelayListEvent.createAddressTag(user.pubkeyHex),
|
||||
)
|
||||
}
|
||||
|
||||
val draftNoteCache = CachedDraftNotes(this)
|
||||
|
||||
class CachedDraftNotes(val accountViewModel: AccountViewModel) : GenericBaseCacheAsync<DraftEvent, Note>(20) {
|
||||
|
Reference in New Issue
Block a user