46 fallback WoT score to bootstrap pubkeys
This commit is contained in:
@@ -15,7 +15,15 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {clamp} from "@welshman/lib"
|
import {clamp} from "@welshman/lib"
|
||||||
import {pubkey, getFollows, deriveUserWotScore} from "@welshman/app"
|
import {
|
||||||
|
pubkey,
|
||||||
|
followLists,
|
||||||
|
muteLists,
|
||||||
|
getFollows,
|
||||||
|
getMutes,
|
||||||
|
deriveUserWotScore,
|
||||||
|
} from "@welshman/app"
|
||||||
|
import {bootstrapPubkeys} from "@app/core/state"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
pubkey: string
|
pubkey: string
|
||||||
@@ -27,9 +35,42 @@
|
|||||||
const radius = 6
|
const radius = 6
|
||||||
const center = radius + 1
|
const center = radius + 1
|
||||||
|
|
||||||
const score = deriveUserWotScore(target)
|
const userScore = deriveUserWotScore(target)
|
||||||
const active = $derived(getFollows($pubkey!).includes(target))
|
const follows = $derived.by(() => {
|
||||||
const normalizedScore = $derived(clamp([0, max], $score) / max)
|
const lists = $followLists
|
||||||
|
|
||||||
|
if (!lists.length || !$pubkey) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return getFollows($pubkey)
|
||||||
|
})
|
||||||
|
const hasUserFollows = $derived(follows.length > 0)
|
||||||
|
const fallbackScore = $derived.by(() => {
|
||||||
|
const lists = $followLists
|
||||||
|
const mutes = $muteLists
|
||||||
|
|
||||||
|
if (!lists.length && !mutes.length) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
let score = 0
|
||||||
|
|
||||||
|
for (const seed of $bootstrapPubkeys) {
|
||||||
|
if (getFollows(seed).includes(target)) {
|
||||||
|
score += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getMutes(seed).includes(target)) {
|
||||||
|
score -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return score
|
||||||
|
})
|
||||||
|
const score = $derived(hasUserFollows ? $userScore : fallbackScore)
|
||||||
|
const active = $derived(follows.includes(target))
|
||||||
|
const normalizedScore = $derived(clamp([0, max], score) / max)
|
||||||
const dashOffset = $derived(100 - 44 * normalizedScore)
|
const dashOffset = $derived(100 - 44 * normalizedScore)
|
||||||
const style = $derived(`transform: rotate(${135 - normalizedScore * 180}deg)`)
|
const style = $derived(`transform: rotate(${135 - normalizedScore * 180}deg)`)
|
||||||
const stroke = $derived(active ? "var(--primary)" : "var(--base-content)")
|
const stroke = $derived(active ? "var(--primary)" : "var(--base-content)")
|
||||||
|
|||||||
Reference in New Issue
Block a user