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