perf: improve loading speed (#116)

This commit is contained in:
Cody Tseng
2025-02-12 22:09:00 +08:00
committed by GitHub
parent 6f91c200a9
commit d5f46690c4
16 changed files with 705 additions and 514 deletions

View File

@@ -2,8 +2,9 @@ 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 indexedDb from '@/services/indexed-db.service'
import { TProfile } from '@/types'
import { kinds } from 'nostr-tools'
import { useEffect, useState } from 'react'
export function useFetchProfile(id?: string) {
@@ -27,7 +28,7 @@ export function useFetchProfile(id?: string) {
const pubkey = userIdToPubkey(id)
setPubkey(pubkey)
const storedProfileEvent = storage.getAccountProfileEvent(pubkey)
const storedProfileEvent = await indexedDb.getReplaceableEvent(pubkey, kinds.Metadata)
if (storedProfileEvent) {
const profile = getProfileFromProfileEvent(storedProfileEvent)
setProfile(profile)