feat: add blocks page
This commit is contained in:
1 parent
661d9b1003
commit
38775168cc
2 files changed
+73
-28
No files matched your search
@@ -7,8 +7,11 @@
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { Icon, Trash } from 'svelte-hero-icons'
|
||||
import { Check, Icon, Trash } from 'svelte-hero-icons'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import { flip } from 'svelte/animate'
|
||||
import { slide } from 'svelte/transition'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
|
||||
// sveltekit doesn't feel like making types work right now
|
||||
export let data: PageData & {
|
||||
@@ -54,30 +57,72 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<SectionTitle>Users</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockUser(i.detail)}>
|
||||
{#each data.person_blocks as block}
|
||||
<div class="flex flex-row gap-4 items-center py-4 justify-between">
|
||||
<UserLink user={block.target} avatar badges />
|
||||
<Button size="square-md" on:click={() => action(block.target)}>
|
||||
<Icon src={Trash} mini size="16" slot="icon" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
</div>
|
||||
{#if data.community_blocks.length > 0 || data.person_blocks.length > 0}
|
||||
{#if data.person_blocks.length > 0}
|
||||
<div>
|
||||
<SectionTitle>Users</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockUser(i.detail)}>
|
||||
{#each data.person_blocks as block (block.target.id)}
|
||||
<div
|
||||
class="flex flex-row gap-4 items-center py-4 justify-between"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide={{ axis: 'y' }}
|
||||
>
|
||||
<UserLink user={block.target} avatar badges />
|
||||
<Button size="square-md" on:click={() => action(block)}>
|
||||
<Icon src={Trash} mini size="16" slot="icon" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
</div>
|
||||
{:else}
|
||||
<Placeholder>
|
||||
<Icon src={Check} size="48" slot="icon" />
|
||||
<span slot="title">No user blocks</span>
|
||||
<p slot="description">
|
||||
Go to a user's profile and click "block" to stop seeing posts and
|
||||
comments from them.
|
||||
</p>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
<SectionTitle>Communities</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockCommunity(i.detail)}>
|
||||
{#each data.community_blocks as block}
|
||||
<div class="flex flex-row gap-4 items-center py-4 justify-between">
|
||||
<CommunityLink community={block.community} avatar />
|
||||
<Button size="square-md" on:click={() => action(block.community)}>
|
||||
<Icon src={Trash} mini size="16" slot="icon" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
</div>
|
||||
{#if data.community_blocks.length > 0}
|
||||
<div>
|
||||
<SectionTitle>Communities</SectionTitle>
|
||||
<EditableList let:action on:action={(i) => unblockCommunity(i.detail)}>
|
||||
{#each data.community_blocks as block (block.community.id)}
|
||||
<div
|
||||
class="flex flex-row gap-4 items-center py-4 justify-between"
|
||||
animate:flip={{ duration: 250 }}
|
||||
out:slide={{ axis: 'y' }}
|
||||
>
|
||||
<CommunityLink community={block.community} avatar />
|
||||
<Button size="square-md" on:click={() => action(block)}>
|
||||
<Icon src={Trash} mini size="16" slot="icon" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
</div>
|
||||
{:else}
|
||||
<Placeholder>
|
||||
<Icon src={Check} size="48" slot="icon" />
|
||||
<span slot="title">No community blocks</span>
|
||||
<p slot="description">
|
||||
Go to a community's page and click "block" to stop seeing submissions
|
||||
from it.
|
||||
</p>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="my-auto">
|
||||
<Placeholder>
|
||||
<Icon src={Check} size="48" slot="icon" />
|
||||
<span slot="title">No blocks</span>
|
||||
<p slot="description">
|
||||
Go to a community or user's page to stop seeing submissions from it.
|
||||
</p>
|
||||
</Placeholder>
|
||||
</div>
|
||||
{/if}
|
||||
Reference in new issue
Block a user