initial desktop phase1
This commit is contained in:
+19
@@ -99,6 +99,25 @@ open class RelayConnectionManager(
|
||||
client.send(event, relays)
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts an event to all configured relays.
|
||||
* Events will be sent to relays as they become connected.
|
||||
*/
|
||||
fun broadcastToAll(event: Event) {
|
||||
// Use all configured relays, not just currently connected ones
|
||||
// The NostrClient will queue/send events as relays connect
|
||||
val configuredRelays = relayStatuses.value.keys
|
||||
val connectedCount = connectedRelays.value.size
|
||||
println("[RelayManager] broadcastToAll: event kind=${event.kind}, ID=${event.id.take(8)}...")
|
||||
println("[RelayManager] Configured relays: ${configuredRelays.size}, Connected: $connectedCount")
|
||||
configuredRelays.forEach { relay ->
|
||||
val isConnected = connectedRelays.value.contains(relay)
|
||||
println("[RelayManager] - $relay: ${if (isConnected) "CONNECTED" else "pending"}")
|
||||
}
|
||||
send(event, configuredRelays)
|
||||
println("[RelayManager] broadcastToAll complete")
|
||||
}
|
||||
|
||||
private fun updateRelayStatus(
|
||||
url: NormalizedRelayUrl,
|
||||
update: (RelayStatus) -> RelayStatus,
|
||||
|
||||
+10
-1
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.commons.ui.note
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -50,6 +51,7 @@ import com.vitorpamplona.amethyst.commons.util.toTimeAgo
|
||||
*/
|
||||
data class NoteDisplayData(
|
||||
val id: String,
|
||||
val pubKeyHex: String,
|
||||
val pubKeyDisplay: String,
|
||||
val content: String,
|
||||
val createdAt: Long,
|
||||
@@ -64,6 +66,7 @@ fun NoteCard(
|
||||
note: NoteDisplayData,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: (() -> Unit)? = null,
|
||||
onAuthorClick: ((String) -> Unit)? = null,
|
||||
) {
|
||||
val richTextParser = remember { RichTextParser() }
|
||||
val urls = remember(note.content) { richTextParser.parseValidUrls(note.content) }
|
||||
@@ -82,12 +85,18 @@ fun NoteCard(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// Author (truncated)
|
||||
// Author (truncated, clickable)
|
||||
Text(
|
||||
text = note.pubKeyDisplay.take(20) + if (note.pubKeyDisplay.length > 20) "..." else "",
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
maxLines = 1,
|
||||
modifier =
|
||||
if (onAuthorClick != null) {
|
||||
Modifier.clickable { onAuthorClick(note.pubKeyHex) }
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
)
|
||||
|
||||
// Timestamp
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ fun Event.toNoteDisplayData(): NoteDisplayData {
|
||||
|
||||
return NoteDisplayData(
|
||||
id = id,
|
||||
pubKeyHex = pubKey,
|
||||
pubKeyDisplay = npub,
|
||||
content = content,
|
||||
createdAt = createdAt,
|
||||
|
||||
Reference in New Issue
Block a user