forked from coracle/flotilla
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84dbe0cfe2 | |||
| f777e26d33 | |||
| 8d4f78ecaf |
@@ -5,8 +5,15 @@
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import ContentLinkDetail from "@app/components/ContentLinkDetail.svelte"
|
||||
import ContentLinkBlockImage from "@app/components/ContentLinkBlockImage.svelte"
|
||||
import RelaySummary from "@app/components/RelaySummary.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {dufflepud, PLATFORM_URL, IMAGE_CONTENT_TYPES, VIDEO_CONTENT_TYPES} from "@app/core/state"
|
||||
import {
|
||||
dufflepud,
|
||||
PLATFORM_URL,
|
||||
IMAGE_CONTENT_TYPES,
|
||||
VIDEO_CONTENT_TYPES,
|
||||
parseInviteLink,
|
||||
} from "@app/core/state"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
|
||||
const {value, event} = $props()
|
||||
@@ -14,6 +21,7 @@
|
||||
let hideImage = $state(false)
|
||||
|
||||
const url = value.url.toString()
|
||||
const inviteData = parseInviteLink(url)
|
||||
const fileType = getTagValue("file-type", event.tags) || ""
|
||||
const [href, external] = call(() => {
|
||||
if (isRelayUrl(url)) return [makeSpacePath(url), false]
|
||||
@@ -49,6 +57,11 @@
|
||||
<button type="button" onclick={stopPropagation(preventDefault(expand))}>
|
||||
<ContentLinkBlockImage {value} {event} class="m-auto max-h-96 rounded-box" />
|
||||
</button>
|
||||
{:else if inviteData}
|
||||
<div class="bg-alt flex max-w-xl flex-col gap-4 p-4 leading-normal">
|
||||
<p class="text-sm opacity-75">Invitation to join a space:</p>
|
||||
<RelaySummary url={inviteData.url} />
|
||||
</div>
|
||||
{:else}
|
||||
{#await loadPreview()}
|
||||
<div class="center my-12 w-full">
|
||||
|
||||
@@ -15,15 +15,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import {clamp} from "@welshman/lib"
|
||||
import {
|
||||
pubkey,
|
||||
followLists,
|
||||
muteLists,
|
||||
getFollows,
|
||||
getMutes,
|
||||
deriveUserWotScore,
|
||||
} from "@welshman/app"
|
||||
import {bootstrapPubkeys} from "@app/core/state"
|
||||
import {pubkey, getFollows, deriveUserWotScore} from "@welshman/app"
|
||||
|
||||
interface Props {
|
||||
pubkey: string
|
||||
@@ -35,45 +27,9 @@
|
||||
const radius = 6
|
||||
const center = radius + 1
|
||||
|
||||
const userScore = deriveUserWotScore(target)
|
||||
const follows = $derived.by(() => {
|
||||
const lists = $followLists
|
||||
|
||||
if (!lists.length || !$pubkey) {
|
||||
return []
|
||||
}
|
||||
|
||||
return getFollows($pubkey)
|
||||
})
|
||||
const userScoreAvailable = $derived(follows.length > 0)
|
||||
const score = $derived.by(() => {
|
||||
if (userScoreAvailable) {
|
||||
return $userScore
|
||||
}
|
||||
|
||||
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 active = $derived(follows.includes(target))
|
||||
const normalizedScore = $derived(clamp([0, max], score) / max)
|
||||
const score = deriveUserWotScore(target)
|
||||
const active = $derived(getFollows($pubkey!).includes(target))
|
||||
const normalizedScore = $derived(clamp([0, max], $score) / max)
|
||||
const dashOffset = $derived(100 - 44 * normalizedScore)
|
||||
const style = $derived(`transform: rotate(${135 - normalizedScore * 180}deg)`)
|
||||
const stroke = $derived(active ? "var(--primary)" : "var(--base-content)")
|
||||
|
||||
Reference in New Issue
Block a user