refactor
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import { BIG_RELAY_URLS, ExtendedKind } from '@/constants'
|
||||
import {
|
||||
extractServersFromTags,
|
||||
getProfileFromProfileEvent,
|
||||
getRelayListFromRelayListEvent
|
||||
} from '@/lib/event'
|
||||
import { getProfileFromEvent, getRelayListFromEvent } from '@/lib/event-metadata'
|
||||
import { formatPubkey, pubkeyToNpub, userIdToPubkey } from '@/lib/pubkey'
|
||||
import { extractPubkeysFromEventTags } from '@/lib/tag'
|
||||
import { getPubkeysFromPTags, getServersFromServerTags } from '@/lib/tag'
|
||||
import { isLocalNetworkUrl, isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
||||
import { ISigner, TProfile, TRelayList } from '@/types'
|
||||
import { sha256 } from '@noble/hashes/sha2'
|
||||
@@ -716,7 +712,7 @@ class ClientService extends EventTarget {
|
||||
async fetchProfile(id: string, skipCache: boolean = false): Promise<TProfile | undefined> {
|
||||
const profileEvent = await this.fetchProfileEvent(id, skipCache)
|
||||
if (profileEvent) {
|
||||
return getProfileFromProfileEvent(profileEvent)
|
||||
return getProfileFromEvent(profileEvent)
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -735,7 +731,7 @@ class ClientService extends EventTarget {
|
||||
|
||||
const profileEvents = events.sort((a, b) => b.created_at - a.created_at)
|
||||
await Promise.all(profileEvents.map((profile) => this.addUsernameToIndex(profile)))
|
||||
return profileEvents.map((profileEvent) => getProfileFromProfileEvent(profileEvent))
|
||||
return profileEvents.map((profileEvent) => getProfileFromEvent(profileEvent))
|
||||
}
|
||||
|
||||
async fetchRelayListEvent(pubkey: string) {
|
||||
@@ -769,7 +765,7 @@ class ClientService extends EventTarget {
|
||||
|
||||
return relayEvents.map((event) => {
|
||||
if (event) {
|
||||
return getRelayListFromRelayListEvent(event)
|
||||
return getRelayListFromEvent(event)
|
||||
}
|
||||
return {
|
||||
write: BIG_RELAY_URLS,
|
||||
@@ -821,7 +817,7 @@ class ClientService extends EventTarget {
|
||||
|
||||
async fetchFollowings(pubkey: string) {
|
||||
const followListEvent = await this.fetchFollowListEvent(pubkey)
|
||||
return followListEvent ? extractPubkeysFromEventTags(followListEvent.tags) : []
|
||||
return followListEvent ? getPubkeysFromPTags(followListEvent.tags) : []
|
||||
}
|
||||
|
||||
async fetchFollowingFavoriteRelays(pubkey: string) {
|
||||
@@ -881,7 +877,7 @@ class ClientService extends EventTarget {
|
||||
|
||||
async fetchBlossomServerList(pubkey: string) {
|
||||
const evt = await this.blossomServerListEventCache.fetch(pubkey)
|
||||
return evt ? extractServersFromTags(evt.tags) : []
|
||||
return evt ? getServersFromServerTags(evt.tags) : []
|
||||
}
|
||||
|
||||
async fetchBlossomServerListEvent(pubkey: string) {
|
||||
|
||||
Reference in New Issue
Block a user