mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 19:36:37 +02:00
Merge pull request #854 from jeremyd/main
allow relay selection dialog to pick any relays
This commit is contained in:
@@ -2435,6 +2435,10 @@ class Account(
|
|||||||
return (activeRelays() ?: convertLocalRelays()).filter { it.write }
|
return (activeRelays() ?: convertLocalRelays()).filter { it.write }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun activeAllRelays(): List<Relay> {
|
||||||
|
return ((activeRelays() ?: convertLocalRelays()).toList())
|
||||||
|
}
|
||||||
|
|
||||||
fun isAllHidden(users: Set<HexKey>): Boolean {
|
fun isAllHidden(users: Set<HexKey>): Boolean {
|
||||||
return users.all { isHidden(it) }
|
return users.all { isHidden(it) }
|
||||||
}
|
}
|
||||||
|
@@ -449,6 +449,38 @@ class Relay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function sends the event regardless of the relay being write or not.
|
||||||
|
fun sendOverride(signedEvent: EventInterface) {
|
||||||
|
checkNotInMainThread()
|
||||||
|
|
||||||
|
if (signedEvent is RelayAuthEvent) {
|
||||||
|
authResponse.put(signedEvent.id, false)
|
||||||
|
// specific protocol for this event.
|
||||||
|
val event = """["AUTH",${signedEvent.toJson()}]"""
|
||||||
|
socket?.send(event)
|
||||||
|
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
||||||
|
} else {
|
||||||
|
val event = """["EVENT",${signedEvent.toJson()}]"""
|
||||||
|
if (isConnected()) {
|
||||||
|
if (isReady) {
|
||||||
|
socket?.send(event)
|
||||||
|
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// sends all filters after connection is successful.
|
||||||
|
connectAndRun {
|
||||||
|
checkNotInMainThread()
|
||||||
|
|
||||||
|
socket?.send(event)
|
||||||
|
eventUploadCounterInBytes += event.bytesUsedInMemory()
|
||||||
|
|
||||||
|
// Sends everything.
|
||||||
|
renewFilters()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun send(signedEvent: EventInterface) {
|
fun send(signedEvent: EventInterface) {
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
|
|
||||||
|
@@ -150,13 +150,17 @@ object RelayPool : Relay.Listener {
|
|||||||
list: List<Relay>,
|
list: List<Relay>,
|
||||||
signedEvent: EventInterface,
|
signedEvent: EventInterface,
|
||||||
) {
|
) {
|
||||||
list.forEach { relay -> relays.filter { it.url == relay.url }.forEach { it.send(signedEvent) } }
|
list.forEach { relay -> relays.filter { it.url == relay.url }.forEach { it.sendOverride(signedEvent) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun send(signedEvent: EventInterface) {
|
fun send(signedEvent: EventInterface) {
|
||||||
relays.forEach { it.send(signedEvent) }
|
relays.forEach { it.send(signedEvent) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sendOverride(signedEvent: EventInterface) {
|
||||||
|
relays.forEach { it.sendOverride(signedEvent) }
|
||||||
|
}
|
||||||
|
|
||||||
fun close(subscriptionId: String) {
|
fun close(subscriptionId: String) {
|
||||||
relays.forEach { it.close(subscriptionId) }
|
relays.forEach { it.close(subscriptionId) }
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ fun RelaySelectionDialog(
|
|||||||
|
|
||||||
var relays by remember {
|
var relays by remember {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
accountViewModel.account.activeWriteRelays().map {
|
accountViewModel.account.activeAllRelays().map {
|
||||||
RelayList(
|
RelayList(
|
||||||
relay = it,
|
relay = it,
|
||||||
relayInfo = RelayBriefInfoCache.RelayBriefInfo(it.url),
|
relayInfo = RelayBriefInfoCache.RelayBriefInfo(it.url),
|
||||||
|
Reference in New Issue
Block a user