Fix wot score overstating mutes, remove impostor, always show wot score

This commit is contained in:
Jonathan Staab 2023-10-23 08:19:36 -07:00
parent 8d3c28b78c
commit 7c189038f4
3 changed files with 16 additions and 59 deletions

View File

@ -2,55 +2,31 @@
import cx from "classnames"
import Popover from "src/partials/Popover.svelte"
import Anchor from "src/partials/Anchor.svelte"
import {
deriveFollowing,
derivePerson,
displayPerson,
session,
follows,
getWotScore,
possibleImposters,
} from "src/engine"
import {deriveFollowing, derivePerson, displayPerson, session, getWotScore} from "src/engine"
export let pubkey
const person = derivePerson(pubkey)
const following = deriveFollowing(pubkey)
const wotScore = follows.derived(pks => {
if (!$session || $following || pubkey === $session.pubkey) {
return null
}
return getWotScore($session.pubkey, pubkey)
})
const mayBeImposter = possibleImposters.derived(pubkeys => pubkeys.has(pubkey))
const wotScore = getWotScore($session.pubkey, pubkey)
</script>
<div class={cx("flex items-center gap-1", $$props.class)}>
<span class="cy-person-name">{displayPerson($person)}</span>
<div class="flex items-center gap-1 font-normal">
{#if $following}
<span class="px-2 py-1 text-xs">
<i class="fa fa-user-check pl-px text-accent" />
</span>
{:else if $mayBeImposter}
<span class="px-2 py-1 text-xs">
<i class="fa fa-warning text-warning" />
</span>
{:else if $wotScore !== null}
<Popover triggerType="mouseenter">
<span slot="trigger" class="px-2 py-1 text-xs">
<Popover triggerType="mouseenter">
<span slot="trigger" class="px-2 py-1 text-xs">
{#if $following}
<i class="fa fa-check-circle text-accent" />
{:else}
<i class="fa fa-diagram-project text-accent" />
{$wotScore}
</span>
<Anchor modal slot="tooltip" class="flex items-center gap-1" href="/help/web-of-trust">
<i class="fa fa-info-circle" />
WoT Score
</Anchor>
</Popover>
{/if}
{/if}
{wotScore}
</span>
<Anchor modal slot="tooltip" class="flex items-center gap-1" href="/help/web-of-trust">
<i class="fa fa-info-circle" />
WoT Score
</Anchor>
</Popover>
</div>
</div>

View File

@ -18,21 +18,3 @@ export const network = user.derived(getNetwork)
export const deriveMuted = (value: string) => mutes.derived(s => s.has(value))
export const deriveFollowing = (pubkey: string) => follows.derived(s => s.has(pubkey))
export const possibleImposters = peopleWithName.throttle(1000).derived($people => {
const pubkeys = new Set()
const seen = new Set()
for (const person of $people) {
const {name, about} = person.profile
const key = `${name}:${about}`
if (seen.has(key)) {
pubkeys.add(person.pubkey)
} else {
seen.add(key)
}
}
return pubkeys
})

View File

@ -114,8 +114,7 @@ export const getFollowsWhoMute = cached({
})
export const getWotScore = (pk, tpk) =>
getFollowsWhoFollow(pk, tpk).length -
Math.pow(2, Math.log(Math.max(1, getFollowsWhoMute(pk, tpk).length)))
getFollowsWhoFollow(pk, tpk).length - Math.pow(2, Math.log(getFollowsWhoMute(pk, tpk).length))
const annotatePerson = pubkey => {
const relays = getPubkeyHints.limit(3).getHints(pubkey, "write")