feat: mute
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getFollowingsFromFollowListEvent } from '@/lib/event'
|
||||
import { extractPubkeysFromEventTags } from '@/lib/tag'
|
||||
import client from '@/services/client.service'
|
||||
import { Event } from 'nostr-tools'
|
||||
import { useEffect, useState } from 'react'
|
||||
@@ -18,7 +18,7 @@ export function useFetchFollowings(pubkey?: string | null) {
|
||||
if (!event) return
|
||||
|
||||
setFollowListEvent(event)
|
||||
setFollowings(getFollowingsFromFollowListEvent(event))
|
||||
setFollowings(extractPubkeysFromEventTags(event.tags))
|
||||
} finally {
|
||||
setIsFetching(false)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import { getProfileFromProfileEvent } from '@/lib/event'
|
||||
import { userIdToPubkey } from '@/lib/pubkey'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import client from '@/services/client.service'
|
||||
import storage from '@/services/storage.service'
|
||||
import { TProfile } from '@/types'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export function useFetchProfile(id?: string) {
|
||||
const { profile: currentAccountProfile } = useNostr()
|
||||
const [isFetching, setIsFetching] = useState(true)
|
||||
const [error, setError] = useState<Error | null>(null)
|
||||
const [profile, setProfile] = useState<TProfile | null>(null)
|
||||
const pubkey = useMemo(() => (id ? userIdToPubkey(id) : undefined), [id])
|
||||
const [pubkey, setPubkey] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setProfile(null)
|
||||
setPubkey(null)
|
||||
const fetchProfile = async () => {
|
||||
setIsFetching(true)
|
||||
try {
|
||||
@@ -21,6 +25,16 @@ export function useFetchProfile(id?: string) {
|
||||
return
|
||||
}
|
||||
|
||||
const pubkey = userIdToPubkey(id)
|
||||
setPubkey(pubkey)
|
||||
const storedProfileEvent = storage.getAccountProfileEvent(pubkey)
|
||||
if (storedProfileEvent) {
|
||||
const profile = getProfileFromProfileEvent(storedProfileEvent)
|
||||
setProfile(profile)
|
||||
setIsFetching(false)
|
||||
return
|
||||
}
|
||||
|
||||
const profile = await client.fetchProfile(id)
|
||||
if (profile) {
|
||||
setProfile(profile)
|
||||
|
||||
Reference in New Issue
Block a user