Add follow/unfollow
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
import {nip19} from "nostr-tools"
|
import {nip19} from "nostr-tools"
|
||||||
import {ctx, sleep, sortBy, flatten} from "@welshman/lib"
|
import {ctx, sleep, sortBy, flatten} from "@welshman/lib"
|
||||||
import {feedFromFilter} from "@welshman/feeds"
|
import {feedFromFilter} from "@welshman/feeds"
|
||||||
import {NOTE, displayProfile, displayPubkey, getAncestorTags} from "@welshman/util"
|
import {NOTE, displayProfile, getListTags, getPubkeyTagValues, displayPubkey, getAncestorTags} from "@welshman/util"
|
||||||
import {deriveEvents} from "@welshman/store"
|
import {deriveEvents} from "@welshman/store"
|
||||||
import {repository, deriveProfile, displayNip05, feedLoader} from "@welshman/app"
|
import {repository, userFollows, tagPubkey, follow, unfollow, deriveProfile, displayNip05, feedLoader} from "@welshman/app"
|
||||||
import {createScroller} from "@lib/html"
|
import {createScroller} from "@lib/html"
|
||||||
import {fly} from "@lib/transition"
|
import {fly} from "@lib/transition"
|
||||||
import Link from "@lib/components/Link.svelte"
|
import Link from "@lib/components/Link.svelte"
|
||||||
@@ -43,20 +43,31 @@
|
|||||||
|
|
||||||
<div class="flex max-w-full flex-col gap-4 p-4" bind:this={element}>
|
<div class="flex max-w-full flex-col gap-4 p-4" bind:this={element}>
|
||||||
{#if $profile}
|
{#if $profile}
|
||||||
<Link external href={entityLink(nprofile)} class="flex max-w-full gap-3">
|
<Link external href={entityLink(nprofile)} class="row-3 max-w-full justify-between">
|
||||||
<div class="py-1">
|
<div class="row-3 min-w-0">
|
||||||
<Avatar src={$profile?.picture} size={10} />
|
<div class="py-1">
|
||||||
</div>
|
<Avatar src={$profile?.picture} size={10} />
|
||||||
<div class="flex min-w-0 flex-col">
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex min-w-0 flex-col">
|
||||||
<div class="text-bold overflow-hidden text-ellipsis">
|
<div class="flex items-center gap-2">
|
||||||
{displayProfile($profile, pubkeyDisplay)}
|
<div class="text-bold overflow-hidden text-ellipsis">
|
||||||
|
{displayProfile($profile, pubkeyDisplay)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="overflow-hidden text-ellipsis text-sm opacity-75">
|
||||||
|
{$profile?.nip05 ? displayNip05($profile.nip05) : pubkeyDisplay}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-hidden text-ellipsis text-sm opacity-75">
|
|
||||||
{$profile?.nip05 ? displayNip05($profile.nip05) : pubkeyDisplay}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
{#if getPubkeyTagValues(getListTags($userFollows)).includes(pubkey)}
|
||||||
|
<button type="button" class="btn btn-neutral" on:click|preventDefault={() => unfollow(pubkey)}>
|
||||||
|
Unfollow
|
||||||
|
</button>
|
||||||
|
{:else}
|
||||||
|
<button type="button" class="btn btn-primary" on:click|preventDefault={() => follow(tagPubkey(pubkey))}>
|
||||||
|
Follow
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</Link>
|
</Link>
|
||||||
<Content event={{content: $profile.about, tags: []}} hideMedia />
|
<Content event={{content: $profile.about, tags: []}} hideMedia />
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
<div slot="title" class="row-2">
|
<div slot="title" class="row-2">
|
||||||
{#if others.length === 1}
|
{#if others.length === 1}
|
||||||
{@const pubkey = others[0]}
|
{@const pubkey = others[0]}
|
||||||
{@const showProfile = () => pushModal(ProfileDetail, {pubkey})}
|
{@const showProfile = () => pushModal(ProfileDetail, {pubkey}, {drawer: true})}
|
||||||
<Button on:click={showProfile} class="row-2">
|
<Button on:click={showProfile} class="row-2">
|
||||||
<ProfileCircle {pubkey} size={5} />
|
<ProfileCircle {pubkey} size={5} />
|
||||||
<ProfileName {pubkey} />
|
<ProfileName {pubkey} />
|
||||||
|
|||||||
Reference in New Issue
Block a user