feat: others relays
This commit is contained in:
@@ -90,10 +90,10 @@ export function getRelayListFromRelayListEvent(event?: Event) {
|
||||
|
||||
const normalizedUrl = normalizeUrl(url)
|
||||
switch (type) {
|
||||
case 'w':
|
||||
case 'write':
|
||||
relayList.write.push(normalizedUrl)
|
||||
break
|
||||
case 'r':
|
||||
case 'read':
|
||||
relayList.read.push(normalizedUrl)
|
||||
break
|
||||
default:
|
||||
@@ -102,8 +102,8 @@ export function getRelayListFromRelayListEvent(event?: Event) {
|
||||
}
|
||||
})
|
||||
return {
|
||||
write: relayList.write.length ? relayList.write.slice(0, 10) : BIG_RELAY_URLS,
|
||||
read: relayList.read.length ? relayList.read.slice(0, 10) : BIG_RELAY_URLS
|
||||
write: relayList.write.length ? relayList.write : BIG_RELAY_URLS,
|
||||
read: relayList.read.length ? relayList.read : BIG_RELAY_URLS
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@ export const toFollowingList = (pubkey: string) => {
|
||||
const npub = nip19.npubEncode(pubkey)
|
||||
return `/users/${npub}/following`
|
||||
}
|
||||
export const toOthersRelaySettings = (pubkey: string) => {
|
||||
const npub = nip19.npubEncode(pubkey)
|
||||
return `/users/${npub}/relays`
|
||||
}
|
||||
export const toRelaySettings = () => '/relay-settings'
|
||||
export const toSettings = () => '/settings'
|
||||
export const toProfileEditor = () => '/profile-editor'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TRelayInfo } from '@/types'
|
||||
import { TMailboxRelay, TRelayInfo, TRelayList } from '@/types'
|
||||
|
||||
export function checkAlgoRelay(relayInfo: TRelayInfo | undefined) {
|
||||
return relayInfo?.software === 'https://github.com/bitvora/algo-relay' // hardcode for now
|
||||
@@ -7,3 +7,16 @@ export function checkAlgoRelay(relayInfo: TRelayInfo | undefined) {
|
||||
export function checkSearchRelay(relayInfo: TRelayInfo | undefined) {
|
||||
return relayInfo?.supported_nips?.includes(50)
|
||||
}
|
||||
|
||||
export function relayListToMailboxRelay(relayList: TRelayList): TMailboxRelay[] {
|
||||
const mailboxRelays: TMailboxRelay[] = relayList.read.map((url) => ({ url, scope: 'read' }))
|
||||
relayList.write.forEach((url) => {
|
||||
const item = mailboxRelays.find((r) => r.url === url)
|
||||
if (item) {
|
||||
item.scope = 'both'
|
||||
} else {
|
||||
mailboxRelays.push({ url, scope: 'write' })
|
||||
}
|
||||
})
|
||||
return mailboxRelays
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user