refactor: 🏗️

This commit is contained in:
codytseng
2025-01-18 15:43:57 +08:00
parent 49933ee4a2
commit 08995d957c
7 changed files with 28 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
import { TMailboxRelay, TRelayInfo, TRelayList } from '@/types'
import { TRelayInfo } from '@/types'
export function checkAlgoRelay(relayInfo: TRelayInfo | undefined) {
return relayInfo?.software === 'https://github.com/bitvora/algo-relay' // hardcode for now
@@ -7,16 +7,3 @@ 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
}