mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 00:59:07 -04:00
do not allow relay hints to be added on nsec screen.
This commit is contained in:
parent
d912a28987
commit
ed16607a36
|
@ -90,7 +90,11 @@ object Components {
|
||||||
sk.map { k => entry("private key (hex)", k.value.toHex) },
|
sk.map { k => entry("private key (hex)", k.value.toHex) },
|
||||||
sk.map { k => entry("nsec", NIP19.encode(k)) },
|
sk.map { k => entry("nsec", NIP19.encode(k)) },
|
||||||
entry("public key (hex)", pp.pubkey.value.toHex),
|
entry("public key (hex)", pp.pubkey.value.toHex),
|
||||||
relayHints(store, pp.relays),
|
relayHints(
|
||||||
|
store,
|
||||||
|
pp.relays,
|
||||||
|
dynamic = if sk.isDefined then false else true
|
||||||
|
),
|
||||||
entry("npub", NIP19.encode(pp.pubkey)),
|
entry("npub", NIP19.encode(pp.pubkey)),
|
||||||
nip19_21("nprofile", NIP19.encode(pp))
|
nip19_21("nprofile", NIP19.encode(pp))
|
||||||
)
|
)
|
||||||
|
@ -238,47 +242,52 @@ object Components {
|
||||||
|
|
||||||
private def relayHints(
|
private def relayHints(
|
||||||
store: Store,
|
store: Store,
|
||||||
relays: List[String]
|
relays: List[String],
|
||||||
|
dynamic: Boolean = true
|
||||||
): Resource[IO, HtmlDivElement[IO]] =
|
): Resource[IO, HtmlDivElement[IO]] =
|
||||||
SignallingRef[IO].of(false).toResource.flatMap { active =>
|
if !dynamic && relays.isEmpty then div("")
|
||||||
val value =
|
else
|
||||||
if relays.size > 0 then relays.reduce((a, b) => s"$a, $b") else ""
|
SignallingRef[IO].of(false).toResource.flatMap { active =>
|
||||||
|
val value =
|
||||||
|
if relays.size > 0 then relays.reduce((a, b) => s"$a, $b") else ""
|
||||||
|
|
||||||
div(
|
div(
|
||||||
cls := "flex items-center space-x-3",
|
cls := "flex items-center space-x-3",
|
||||||
span(cls := "font-bold", "relay hints "),
|
span(cls := "font-bold", "relay hints "),
|
||||||
span(Styles.mono, cls := "max-w-xl", value),
|
span(Styles.mono, cls := "max-w-xl", value),
|
||||||
active.map {
|
active.map {
|
||||||
case true =>
|
case true =>
|
||||||
div(
|
div(
|
||||||
input.withSelf { self =>
|
input.withSelf { self =>
|
||||||
(
|
(
|
||||||
onKeyPress --> (_.foreach(evt =>
|
onKeyPress --> (_.foreach(evt =>
|
||||||
evt.key match {
|
evt.key match {
|
||||||
case "Enter" =>
|
case "Enter" =>
|
||||||
self.value.get.flatMap(url =>
|
self.value.get.flatMap(url =>
|
||||||
if url.startsWith("wss://") || url.startsWith("ws://")
|
if url.startsWith("wss://") || url
|
||||||
then
|
.startsWith("ws://")
|
||||||
store.input.update(
|
then
|
||||||
_.trim() ++ " + " ++ url
|
store.input.update(
|
||||||
) >> active.set(false)
|
_.trim() ++ " + " ++ url
|
||||||
else IO.unit
|
) >> active.set(false)
|
||||||
)
|
else IO.unit
|
||||||
case _ => IO.unit
|
)
|
||||||
}
|
case _ => IO.unit
|
||||||
))
|
}
|
||||||
)
|
))
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
case false =>
|
)
|
||||||
button(
|
case false if dynamic =>
|
||||||
Styles.buttonSmall,
|
button(
|
||||||
"add relay hint",
|
Styles.buttonSmall,
|
||||||
onClick --> (_.foreach(_ => active.set(true)))
|
"add relay hint",
|
||||||
)
|
onClick --> (_.foreach(_ => active.set(true)))
|
||||||
}
|
)
|
||||||
)
|
case false => div("")
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private val external = img(cls := "inline w-4 ml-2", src := "ext.svg")
|
private val external = img(cls := "inline w-4 ml-2", src := "ext.svg")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user