feat: bypass IndexedDB cache when viewing user profile
This commit is contained in:
@@ -4,7 +4,7 @@ import client from '@/services/client.service'
|
|||||||
import { TProfile } from '@/types'
|
import { TProfile } from '@/types'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
export function useFetchProfile(id?: string) {
|
export function useFetchProfile(id?: string, skipCache = false) {
|
||||||
const { profile: currentAccountProfile } = useNostr()
|
const { profile: currentAccountProfile } = useNostr()
|
||||||
const [isFetching, setIsFetching] = useState(true)
|
const [isFetching, setIsFetching] = useState(true)
|
||||||
const [error, setError] = useState<Error | null>(null)
|
const [error, setError] = useState<Error | null>(null)
|
||||||
@@ -25,7 +25,7 @@ export function useFetchProfile(id?: string) {
|
|||||||
|
|
||||||
const pubkey = userIdToPubkey(id)
|
const pubkey = userIdToPubkey(id)
|
||||||
setPubkey(pubkey)
|
setPubkey(pubkey)
|
||||||
const profile = await client.fetchProfile(id)
|
const profile = await client.fetchProfile(id, skipCache)
|
||||||
if (profile) {
|
if (profile) {
|
||||||
setProfile(profile)
|
setProfile(profile)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import Relays from './Relays'
|
|||||||
const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref) => {
|
const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { push } = useSecondaryPage()
|
const { push } = useSecondaryPage()
|
||||||
const { profile, isFetching } = useFetchProfile(id)
|
const { profile, isFetching } = useFetchProfile(id, true)
|
||||||
const { pubkey: accountPubkey } = useNostr()
|
const { pubkey: accountPubkey } = useNostr()
|
||||||
const { mutePubkeys } = useMuteList()
|
const { mutePubkeys } = useMuteList()
|
||||||
const { followings } = useFetchFollowings(profile?.pubkey)
|
const { followings } = useFetchFollowings(profile?.pubkey)
|
||||||
|
|||||||
@@ -686,12 +686,7 @@ class ClientService extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetchProfile(id: string, skipCache: boolean = false): Promise<TProfile | undefined> {
|
async fetchProfile(id: string, skipCache: boolean = false): Promise<TProfile | undefined> {
|
||||||
let profileEvent: NEvent | undefined
|
const profileEvent = await this.fetchProfileEvent(id, skipCache)
|
||||||
if (skipCache) {
|
|
||||||
profileEvent = await this.fetchProfileEvent(id, skipCache)
|
|
||||||
} else {
|
|
||||||
profileEvent = await this.fetchProfileEvent(id)
|
|
||||||
}
|
|
||||||
if (profileEvent) {
|
if (profileEvent) {
|
||||||
return getProfileFromProfileEvent(profileEvent)
|
return getProfileFromProfileEvent(profileEvent)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user