mirror of
https://github.com/vitorpamplona/Nostryfied.git
synced 2025-07-22 21:25:32 +00:00
Adding relay options
This commit is contained in:
parent
0d8073db51
commit
97d34a455c
34
index.html
34
index.html
@ -50,6 +50,24 @@
|
|||||||
<form>
|
<form>
|
||||||
<div>
|
<div>
|
||||||
<form>
|
<form>
|
||||||
|
<div class="space-between-small">
|
||||||
|
<div class="space-between">
|
||||||
|
<b>From Relays</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-between-small">
|
||||||
|
<p>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="relaySet"
|
||||||
|
name="relaySet"
|
||||||
|
placeholder="wss://nos.lol"
|
||||||
|
style="width: 180px"
|
||||||
|
value="" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="space-between-small">
|
<div class="space-between-small">
|
||||||
<p>
|
<p>
|
||||||
<input
|
<input
|
||||||
@ -103,6 +121,22 @@
|
|||||||
#pubkey::placeholder {
|
#pubkey::placeholder {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#relaySet {
|
||||||
|
width: 600px; /* change width value */
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#relaySet::placeholder {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -18,6 +18,8 @@ const fetchAndBroadcast = async () => {
|
|||||||
}
|
}
|
||||||
$('#checking-relays-header').text("Waiting for Relays: ")
|
$('#checking-relays-header').text("Waiting for Relays: ")
|
||||||
// parse pubkey ('npub' or hexa)
|
// parse pubkey ('npub' or hexa)
|
||||||
|
const relaySet = parseRelaySet($('#relaySet').val())
|
||||||
|
console.log(relaySet, $('#relaySet').val())
|
||||||
const pubkey = parsePubkey($('#pubkey').val())
|
const pubkey = parsePubkey($('#pubkey').val())
|
||||||
if (!pubkey) return
|
if (!pubkey) return
|
||||||
// disable button (will be re-enable at the end of the process)
|
// disable button (will be re-enable at the end of the process)
|
||||||
@ -35,7 +37,7 @@ const fetchAndBroadcast = async () => {
|
|||||||
|
|
||||||
// get all events from relays
|
// get all events from relays
|
||||||
const filters =[{ authors: [pubkey] }, { "#p": [pubkey] }]
|
const filters =[{ authors: [pubkey] }, { "#p": [pubkey] }]
|
||||||
const data = (await getEvents(filters, pubkey)).sort((a, b) => b.created_at - a.created_at)
|
const data = (await getEvents(filters, pubkey, relaySet)).sort((a, b) => b.created_at - a.created_at)
|
||||||
|
|
||||||
// inform user fetching is done
|
// inform user fetching is done
|
||||||
$('#fetching-status').html(txt.fetching + checkMark)
|
$('#fetching-status').html(txt.fetching + checkMark)
|
||||||
|
@ -37,6 +37,15 @@ const hexa2npub = (hex) => {
|
|||||||
const parsePubkey = (pubkey) =>
|
const parsePubkey = (pubkey) =>
|
||||||
pubkey.match('npub1') ? npub2hexa(pubkey) : pubkey
|
pubkey.match('npub1') ? npub2hexa(pubkey) : pubkey
|
||||||
|
|
||||||
|
const parseRelaySet = (commaSeparatedRelayString) => {
|
||||||
|
let list = commaSeparatedRelayString.split(",")
|
||||||
|
|
||||||
|
if (list.length == 0) return undefined
|
||||||
|
if (list.length == 1 && list[0].trim() === "") return undefined
|
||||||
|
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
// download js file
|
// download js file
|
||||||
const downloadFile = (data, fileName) => {
|
const downloadFile = (data, fileName) => {
|
||||||
const prettyJs = 'const data = ' + JSON.stringify(data, null, 2)
|
const prettyJs = 'const data = ' + JSON.stringify(data, null, 2)
|
||||||
@ -242,12 +251,19 @@ const fetchFromRelay = async (relay, filters, pubkey, events, relayStatus) =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
// query relays for events published by this pubkey
|
// query relays for events published by this pubkey
|
||||||
const getEvents = async (filters, pubkey) => {
|
const getEvents = async (filters, pubkey, relaySet) => {
|
||||||
// events hash
|
// events hash
|
||||||
const events = {}
|
const events = {}
|
||||||
|
|
||||||
|
let myRelaySet = null
|
||||||
|
|
||||||
|
if (relaySet.length > 0)
|
||||||
|
myRelaySet = relaySet
|
||||||
|
else
|
||||||
|
myRelaySet = relays
|
||||||
|
|
||||||
// batch processing of 10 relays
|
// batch processing of 10 relays
|
||||||
await processInPool(relays, (relay, poolStatus) => fetchFromRelay(relay, filters, pubkey, events, poolStatus), 10)
|
await processInPool(myRelaySet, (relay, poolStatus) => fetchFromRelay(relay, filters, pubkey, events, poolStatus), 10)
|
||||||
|
|
||||||
displayRelayStatus({})
|
displayRelayStatus({})
|
||||||
|
|
||||||
|
22
style.css
22
style.css
@ -214,6 +214,28 @@ h2 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#relaySet {
|
||||||
|
width: 600px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1080px) {
|
||||||
|
#relaySet {
|
||||||
|
width: 450px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 800px) {
|
||||||
|
#relaySet {
|
||||||
|
width: 350px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
#relaySet {
|
||||||
|
width: 250px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main div p img {
|
main div p img {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user