Refactor WotScore fallback to compute only when needed
This commit is contained in:
@@ -45,8 +45,12 @@
|
|||||||
|
|
||||||
return getFollows($pubkey)
|
return getFollows($pubkey)
|
||||||
})
|
})
|
||||||
const hasUserFollows = $derived(follows.length > 0)
|
const userScoreAvailable = $derived(follows.length > 0)
|
||||||
const fallbackScore = $derived.by(() => {
|
const score = $derived.by(() => {
|
||||||
|
if (userScoreAvailable) {
|
||||||
|
return $userScore
|
||||||
|
}
|
||||||
|
|
||||||
const lists = $followLists
|
const lists = $followLists
|
||||||
const mutes = $muteLists
|
const mutes = $muteLists
|
||||||
|
|
||||||
@@ -68,7 +72,6 @@
|
|||||||
|
|
||||||
return score
|
return score
|
||||||
})
|
})
|
||||||
const score = $derived(hasUserFollows ? $userScore : fallbackScore)
|
|
||||||
const active = $derived(follows.includes(target))
|
const active = $derived(follows.includes(target))
|
||||||
const normalizedScore = $derived(clamp([0, max], score) / max)
|
const normalizedScore = $derived(clamp([0, max], score) / max)
|
||||||
const dashOffset = $derived(100 - 44 * normalizedScore)
|
const dashOffset = $derived(100 - 44 * normalizedScore)
|
||||||
|
|||||||
Reference in New Issue
Block a user