feat: 💨
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import { useUserTrust } from '@/providers/UserTrustProvider'
|
||||
import trustScoreService from '@/services/trust-score.service'
|
||||
import { AlertTriangle, ShieldAlert } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
@@ -13,6 +14,7 @@ export default function TrustScoreBadge({
|
||||
className?: string
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { isUserTrusted } = useUserTrust()
|
||||
const { pubkey: currentPubkey } = useNostr()
|
||||
const [percentile, setPercentile] = useState<number | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
@@ -24,6 +26,12 @@ export default function TrustScoreBadge({
|
||||
return
|
||||
}
|
||||
|
||||
if (isUserTrusted(pubkey)) {
|
||||
setLoading(false)
|
||||
setPercentile(null)
|
||||
return
|
||||
}
|
||||
|
||||
const fetchScore = async () => {
|
||||
try {
|
||||
const data = await trustScoreService.fetchTrustScore(pubkey)
|
||||
@@ -38,7 +46,7 @@ export default function TrustScoreBadge({
|
||||
}
|
||||
|
||||
fetchScore()
|
||||
}, [pubkey, currentPubkey])
|
||||
}, [pubkey, currentPubkey, isUserTrusted])
|
||||
|
||||
if (loading || percentile === null) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user