design: redesign blocked pages to not look like buns
This commit is contained in:
16 files changed
+336
-271
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { Header, Tabs } from '$lib/ui/layout'
|
||||
|
||||
let { children } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>
|
||||
{$t('routes.profile.blocks.title')}
|
||||
|
||||
{#snippet extended()}
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
href: '/profile/blocks/users',
|
||||
name: $t('content.users'),
|
||||
},
|
||||
{
|
||||
href: '/profile/blocks/communities',
|
||||
name: $t('content.communities'),
|
||||
},
|
||||
{
|
||||
href: '/profile/blocks/instances',
|
||||
name: $t('content.instances'),
|
||||
},
|
||||
]}
|
||||
style="subpage"
|
||||
margin={false}
|
||||
/>
|
||||
{/snippet}
|
||||
</Header>
|
||||
|
||||
{@render children?.()}
|
||||
@@ -1,185 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { client } from '$lib/api/client.svelte'
|
||||
import type {
|
||||
CommunityBlockView,
|
||||
InstanceBlockView,
|
||||
PersonBlockView,
|
||||
} from '$lib/api/types'
|
||||
import { profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import CommunityLink from '$lib/feature/community/CommunityLink.svelte'
|
||||
import UserLink from '$lib/feature/user/UserLink.svelte'
|
||||
import Entity from '$lib/ui/generic/Entity.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import { CommonList, Header } from '$lib/ui/layout'
|
||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Check, XMark } from 'svelte-hero-icons/dist'
|
||||
import type { PageData } from './$types'
|
||||
|
||||
interface Props {
|
||||
// sveltekit doesn't feel like making types work right now
|
||||
data: PageData & {
|
||||
person_blocks: PersonBlockView[]
|
||||
community_blocks: CommunityBlockView[]
|
||||
}
|
||||
}
|
||||
|
||||
let { data: pageData }: Props = $props()
|
||||
let data = $state(pageData)
|
||||
|
||||
async function unblockUser(item: PersonBlockView) {
|
||||
if (!profile.current?.jwt) return
|
||||
|
||||
data.person_blocks.splice(
|
||||
data.person_blocks.findIndex((i) => i.target.id == item.target.id),
|
||||
1,
|
||||
)
|
||||
// hack to get reactivity working
|
||||
data.person_blocks = data.person_blocks
|
||||
|
||||
await client().blockPerson({
|
||||
block: false,
|
||||
person_id: item.target.id,
|
||||
})
|
||||
}
|
||||
|
||||
async function unblockCommunity(item: CommunityBlockView) {
|
||||
if (!profile.current?.jwt) return
|
||||
|
||||
data.community_blocks.splice(
|
||||
data.community_blocks.findIndex(
|
||||
(i) => i.community.id == item.community.id,
|
||||
),
|
||||
1,
|
||||
)
|
||||
|
||||
// hack to get reactivity working
|
||||
data.community_blocks = data.community_blocks
|
||||
|
||||
await client().blockCommunity({
|
||||
block: false,
|
||||
community_id: item.community.id,
|
||||
})
|
||||
}
|
||||
|
||||
async function unblockInstances(item: InstanceBlockView) {
|
||||
if (!profile.current?.jwt) return
|
||||
if (!data.my_user?.instance_blocks) return
|
||||
|
||||
data.my_user.instance_blocks.splice(
|
||||
data.my_user.instance_blocks.findIndex(
|
||||
(i) => i.instance.id == item.instance.id,
|
||||
),
|
||||
1,
|
||||
)
|
||||
data.my_user.instance_blocks = data.my_user.instance_blocks
|
||||
|
||||
await client().blockInstance({
|
||||
block: false,
|
||||
instance_id: item.instance.id,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Header pageHeader>
|
||||
{$t('routes.profile.blocks.title')}
|
||||
</Header>
|
||||
|
||||
<div>
|
||||
{#if data.community_blocks?.length > 0 || data.person_blocks?.length > 0 || (data.my_user?.instance_blocks?.length ?? 0) > 0}
|
||||
{#if data.community_blocks?.length > 0}
|
||||
<EndPlaceholder size="md" margin="md">
|
||||
{$t('content.communities')}
|
||||
</EndPlaceholder>
|
||||
<div class="max-h-96 overflow-auto rounded-2xl">
|
||||
<CommonList
|
||||
size="xs"
|
||||
class="px-3 py-2"
|
||||
animate={false}
|
||||
items={data.community_blocks}
|
||||
>
|
||||
{#snippet item(block)}
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<CommunityLink community={block.community} avatar />
|
||||
<div class="flex-1"></div>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
onclick={() => unblockCommunity(block)}
|
||||
icon={XMark}
|
||||
></Button>
|
||||
</div>
|
||||
{/snippet}
|
||||
</CommonList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.person_blocks?.length > 0}
|
||||
<EndPlaceholder size="md" margin="md">
|
||||
{$t('content.users')}
|
||||
</EndPlaceholder>
|
||||
<div class="max-h-96 overflow-auto rounded-2xl">
|
||||
<CommonList
|
||||
size="xs"
|
||||
class="px-3 py-2"
|
||||
animate={false}
|
||||
items={data.person_blocks}
|
||||
>
|
||||
{#snippet item(block)}
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<UserLink user={block.target} avatar badges />
|
||||
<div class="flex-1"></div>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
onclick={() => unblockUser(block)}
|
||||
icon={XMark}
|
||||
></Button>
|
||||
</div>
|
||||
{/snippet}
|
||||
</CommonList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0}
|
||||
<EndPlaceholder size="md" margin="md" class="text-lg">
|
||||
{$t('content.instances')}
|
||||
</EndPlaceholder>
|
||||
<div class="max-h-96 overflow-auto rounded-2xl">
|
||||
<CommonList
|
||||
size="xs"
|
||||
animate={false}
|
||||
items={data.my_user.instance_blocks}
|
||||
class="px-3 py-2"
|
||||
>
|
||||
{#snippet item(block)}
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<Entity
|
||||
icon={block.site?.icon}
|
||||
name={block.site?.name ?? block.instance.domain}
|
||||
label={block.instance.domain}
|
||||
/>
|
||||
<div class="flex-1"></div>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
onclick={() => unblockInstances(block)}
|
||||
icon={XMark}
|
||||
></Button>
|
||||
</div>
|
||||
{/snippet}
|
||||
</CommonList>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="h-full w-full grid place-items-center">
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title={$t('routes.profile.blocks.empty.title')}
|
||||
description={$t('routes.profile.blocks.empty.description')}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
|
||||
export function load() {
|
||||
redirect(302, '/profile/blocks/users')
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { communityLink } from '$lib/app/util.svelte.js'
|
||||
import ItemList from '$lib/ui/generic/ItemList.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { ArrowUturnUp, Check, Trash } from 'svelte-hero-icons/dist'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
async function unblock(id: number) {
|
||||
if (!data.community_blocks) return
|
||||
data.community_blocks.splice(
|
||||
data.community_blocks.findIndex((i) => i.community.id == id),
|
||||
1,
|
||||
)
|
||||
|
||||
await profile.client.blockCommunity({
|
||||
block: false,
|
||||
community_id: id,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data.community_blocks && data.community_blocks?.length > 0}
|
||||
<ItemList
|
||||
items={data.community_blocks.map((i) => ({
|
||||
id: i.community.id,
|
||||
name: i.community.title,
|
||||
avatar: i.community.icon,
|
||||
url: communityLink(i.community),
|
||||
instance: new URL(i.community.actor_id).hostname,
|
||||
}))}
|
||||
link={false}
|
||||
>
|
||||
{#snippet action(block)}
|
||||
<Button
|
||||
title={$t('common.jump')}
|
||||
size="square-md"
|
||||
href={block.url}
|
||||
color="primary"
|
||||
icon={ArrowUturnUp}
|
||||
/>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
onclick={() => unblock(block.id)}
|
||||
icon={Trash}
|
||||
/>
|
||||
{/snippet}
|
||||
</ItemList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
title={$t('routes.profile.blocks.empty.community.title')}
|
||||
description={$t('routes.profile.blocks.empty.community.description')}
|
||||
icon={Check}
|
||||
class="my-auto"
|
||||
/>
|
||||
{/if}
|
||||
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import ItemList from '$lib/ui/generic/ItemList.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Check, Trash } from 'svelte-hero-icons/dist'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
async function unblock(id: number) {
|
||||
if (!data.my_user?.instance_blocks) return
|
||||
data.my_user?.instance_blocks.splice(
|
||||
data.my_user?.instance_blocks.findIndex((i) => i.instance.id == id),
|
||||
1,
|
||||
)
|
||||
|
||||
await profile.client.blockInstance({
|
||||
block: false,
|
||||
instance_id: id,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data.my_user?.instance_blocks && data.my_user?.instance_blocks?.length > 0}
|
||||
<ItemList
|
||||
items={data.my_user?.instance_blocks.map((i) => ({
|
||||
id: i.instance.id,
|
||||
name: i.site?.name ?? i.instance.domain,
|
||||
avatar: i.site?.icon,
|
||||
instance: i.instance.domain,
|
||||
}))}
|
||||
link={false}
|
||||
>
|
||||
{#snippet action(block)}
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
onclick={() => unblock(block.id)}
|
||||
icon={Trash}
|
||||
/>
|
||||
{/snippet}
|
||||
</ItemList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
title={$t('routes.profile.blocks.empty.instance.title')}
|
||||
description={$t('routes.profile.blocks.empty.instance.description')}
|
||||
icon={Check}
|
||||
class="my-auto"
|
||||
/>
|
||||
{/if}
|
||||
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { userLink } from '$lib/app/util.svelte.js'
|
||||
import ItemList from '$lib/ui/generic/ItemList.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { ArrowUturnUp, Check, Trash } from 'svelte-hero-icons/dist'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
async function unblock(id: number) {
|
||||
if (!data.person_blocks) return
|
||||
data.person_blocks.splice(
|
||||
data.person_blocks.findIndex((i) => i.person.id == id),
|
||||
1,
|
||||
)
|
||||
|
||||
await profile.client.blockPerson({
|
||||
block: false,
|
||||
person_id: id,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data.person_blocks && data.person_blocks?.length > 0}
|
||||
<ItemList
|
||||
items={data.person_blocks.map((i) => ({
|
||||
id: i.target.id,
|
||||
name: i.target.name,
|
||||
avatar: i.target.avatar,
|
||||
url: userLink(i.target),
|
||||
instance: new URL(i.target.actor_id).hostname,
|
||||
circle: true,
|
||||
}))}
|
||||
link={false}
|
||||
>
|
||||
{#snippet action(block)}
|
||||
<Button
|
||||
title={$t('common.jump')}
|
||||
size="square-md"
|
||||
href={block.url}
|
||||
color="primary"
|
||||
icon={ArrowUturnUp}
|
||||
/>
|
||||
<Button
|
||||
title="Unblock"
|
||||
size="square-md"
|
||||
onclick={() => unblock(block.id)}
|
||||
icon={Trash}
|
||||
/>
|
||||
{/snippet}
|
||||
</ItemList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
title={$t('routes.profile.blocks.empty.user.title')}
|
||||
description={$t('routes.profile.blocks.empty.user.description')}
|
||||
icon={Check}
|
||||
class="my-auto"
|
||||
/>
|
||||
{/if}
|
||||
@@ -17,54 +17,52 @@
|
||||
<title>{$t('profile.profile')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="flex flex-col gap-4 h-full z-0">
|
||||
<div class="flex flex-row justify-between">
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
href: '/profile/user',
|
||||
name: $t('routes.profile.submissions'),
|
||||
},
|
||||
<div class="flex flex-row justify-between">
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
href: '/profile/user',
|
||||
name: $t('routes.profile.submissions'),
|
||||
},
|
||||
|
||||
{
|
||||
href: '/profile/settings',
|
||||
name: $t('routes.profile.edit'),
|
||||
},
|
||||
{
|
||||
href: '/profile/settings',
|
||||
name: $t('routes.profile.edit'),
|
||||
},
|
||||
|
||||
{
|
||||
href: '/profile/blocks',
|
||||
name: $t('routes.profile.blocks.title'),
|
||||
},
|
||||
{
|
||||
href: '/profile/blocks',
|
||||
name: $t('routes.profile.blocks.title'),
|
||||
},
|
||||
|
||||
{
|
||||
href: '/profile/password',
|
||||
name: $t('routes.profile.credentials'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Menu class="flex-1" placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button
|
||||
{@attach attachment}
|
||||
aria-label={$t('post.actions.more.label')}
|
||||
size="square-sm"
|
||||
color="none"
|
||||
class="z-0 text-slate-600 dark:text-zinc-500 hover:bg-slate-100 hover:dark:bg-zinc-800"
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton href="/profile/media" icon={Photo}>
|
||||
{$t('routes.profile.media.title')}
|
||||
</MenuButton>
|
||||
<MenuButton href="/profile/voted/up" icon={ArrowUp}>
|
||||
{$t('routes.profile.upvoted')}
|
||||
</MenuButton>
|
||||
<MenuButton href="/profile/voted/down" icon={ArrowDown}>
|
||||
{$t('routes.profile.downvoted')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</Tabs>
|
||||
</div>
|
||||
{@render children?.()}
|
||||
{
|
||||
href: '/profile/password',
|
||||
name: $t('routes.profile.credentials'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Menu class="flex-1" placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button
|
||||
{@attach attachment}
|
||||
aria-label={$t('post.actions.more.label')}
|
||||
size="square-sm"
|
||||
color="none"
|
||||
class="z-0 text-slate-600 dark:text-zinc-500 hover:bg-slate-100 hover:dark:bg-zinc-800"
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton href="/profile/media" icon={Photo}>
|
||||
{$t('routes.profile.media.title')}
|
||||
</MenuButton>
|
||||
<MenuButton href="/profile/voted/up" icon={ArrowUp}>
|
||||
{$t('routes.profile.upvoted')}
|
||||
</MenuButton>
|
||||
<MenuButton href="/profile/voted/down" icon={ArrowDown}>
|
||||
{$t('routes.profile.downvoted')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</Tabs>
|
||||
</div>
|
||||
{@render children?.()}
|
||||
@@ -9,7 +9,7 @@ export async function load({ fetch }) {
|
||||
if (!profile.current.jwt) error(401)
|
||||
|
||||
const my_user =
|
||||
// profile.current?.user ??
|
||||
profile.current?.user ??
|
||||
(await client({ auth: profile.current?.jwt, func: fetch }).getSite())
|
||||
.my_user
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
page: data.page,
|
||||
sort: data.sort,
|
||||
type: data.type,
|
||||
limit: data.limit,
|
||||
}),
|
||||
person_view: { value: data.user.person_view },
|
||||
moderates: { value: data.user.moderates },
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
import { getClient } from '$lib/api/client.svelte'
|
||||
import { client } from '$lib/api/client.svelte'
|
||||
import type { SortType } from '$lib/api/types'
|
||||
import { feed } from '$lib/feature/feeds/feed.svelte.js'
|
||||
import { getItemPublished } from '$lib/feature/legacy/item'
|
||||
|
||||
export async function load({ url, fetch, parent }) {
|
||||
export async function load({ url, fetch, parent, route }) {
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const type: 'comments' | 'posts' | 'all' =
|
||||
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New'
|
||||
|
||||
const { my_user } = await parent()
|
||||
|
||||
const user = await getClient(undefined, fetch).getPersonDetails({
|
||||
const myUser = await parent()
|
||||
const feedData = await feed(route.id, (params) =>
|
||||
client({ func: fetch }).getPersonDetails({
|
||||
limit: params.limit,
|
||||
page: params.page,
|
||||
person_id: myUser?.my_user?.local_user_view.person.id,
|
||||
sort: params.sort,
|
||||
}),
|
||||
).load({
|
||||
limit: 20,
|
||||
page: page,
|
||||
username: my_user?.local_user_view.person.name,
|
||||
person_id: myUser.my_user?.local_user_view.person.id,
|
||||
sort: sort,
|
||||
})
|
||||
|
||||
const items = [
|
||||
...(type == 'all' || type == 'posts' ? user.posts : []),
|
||||
...(type == 'all' || type == 'comments' ? user.comments : []),
|
||||
...(type == 'all' || type == 'posts' ? feedData.posts : []),
|
||||
...(type == 'all' || type == 'comments' ? feedData.comments : []),
|
||||
]
|
||||
|
||||
if (sort == 'TopAll') {
|
||||
@@ -40,10 +47,11 @@ export async function load({ url, fetch, parent }) {
|
||||
type: type,
|
||||
page: page,
|
||||
sort: sort,
|
||||
limit: 20,
|
||||
user: {
|
||||
submissions: items,
|
||||
moderates: user.moderates,
|
||||
person_view: user.person_view,
|
||||
moderates: feedData.moderates,
|
||||
person_view: feedData.person_view,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ export async function load({ params, url, fetch }) {
|
||||
type: type,
|
||||
page: page,
|
||||
sort: sort,
|
||||
limit: 20,
|
||||
}),
|
||||
person_view: new ReactiveState(user.person_view),
|
||||
moderates: new ReactiveState(user.moderates),
|
||||
|
||||
@@ -162,11 +162,26 @@
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() =>
|
||||
blockUser(
|
||||
isBlocked(profile.current.user!, person.person.id),
|
||||
onclick={async () => {
|
||||
const res = await blockUser(
|
||||
!isBlocked(profile.current.user!, person.person.id),
|
||||
person.person.id,
|
||||
)}
|
||||
)
|
||||
|
||||
if (res.blocked) {
|
||||
// TODO technically invalid but i don't use it so idc
|
||||
profile.current.user!.person_blocks.push({
|
||||
person: person.person,
|
||||
target: person.person,
|
||||
})
|
||||
} else {
|
||||
const index = profile.current.user!.person_blocks.findIndex(
|
||||
(i) => i.target.id == person.person.id,
|
||||
)
|
||||
if (index != -1)
|
||||
profile.current.user!.person_blocks.splice(index, 1)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
|
||||
Reference in new issue
Block a user