design: redesign blocked pages to not look like buns
This commit is contained in:
16 files changed
+336
-271
No files matched your search
@@ -84,14 +84,14 @@
|
|||||||
"time": {
|
"time": {
|
||||||
"label": "Period",
|
"label": "Period",
|
||||||
"all": "All time",
|
"all": "All time",
|
||||||
"9months": "Past 9 months",
|
"9months": "9 months",
|
||||||
"6months": "Past 6 months",
|
"6months": "6 months",
|
||||||
"3months": "Past 3 months",
|
"3months": "3 months",
|
||||||
"month": "Past month",
|
"month": "Past month",
|
||||||
"week": "Past week",
|
"week": "Past week",
|
||||||
"day": "Past day",
|
"day": "Past day",
|
||||||
"12hours": "Past 12 hours",
|
"12hours": "12 hours",
|
||||||
"6hours": "Past 6 hours",
|
"6hours": "6 hours",
|
||||||
"hour": "Past hour"
|
"hour": "Past hour"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -250,8 +250,18 @@
|
|||||||
"blocks": {
|
"blocks": {
|
||||||
"title": "Blocked",
|
"title": "Blocked",
|
||||||
"empty": {
|
"empty": {
|
||||||
"title": "No blocked entities",
|
"user": {
|
||||||
"description": "When you block anything, it will no longer appear in your feeds."
|
"title": "No blocked users",
|
||||||
|
"description": "Blocking a user will hide the user's posts and comments from feeds."
|
||||||
|
},
|
||||||
|
"community": {
|
||||||
|
"title": "No blocked communities",
|
||||||
|
"description": "Blocking a community will hide its posts from feeds."
|
||||||
|
},
|
||||||
|
"instance": {
|
||||||
|
"title": "No blocked servers",
|
||||||
|
"description": "Blocking a server will hide posts from its communities from feeds."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"credentials": "Credentials",
|
"credentials": "Credentials",
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export interface FeedTypes {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
'/profile/user': [GetPersonDetails, GetPersonDetailsResponse]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
export const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
||||||
|
|||||||
@@ -4,18 +4,14 @@ import { profile, type ProfileInfo } from '$lib/app/auth.svelte'
|
|||||||
|
|
||||||
// TODO obliterate this file
|
// TODO obliterate this file
|
||||||
export async function blockUser(block: boolean, id: number) {
|
export async function blockUser(block: boolean, id: number) {
|
||||||
const auth = profile.current?.jwt
|
return await client().blockPerson({
|
||||||
|
|
||||||
if (!auth) throw new Error('Unauthorized')
|
|
||||||
|
|
||||||
await client().blockPerson({
|
|
||||||
block: block,
|
block: block,
|
||||||
person_id: id,
|
person_id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isBlocked(me: MyUserInfo, user: number) {
|
export function isBlocked(me: MyUserInfo, user: number) {
|
||||||
return me.person_blocks.map((b) => b.target.id).includes(user)
|
return me.person_blocks.find((b) => b.target.id == user)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addSubscription(
|
export function addSubscription(
|
||||||
|
|||||||
@@ -1,19 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
import { CommonList } from '../layout'
|
import { CommonList } from '../layout'
|
||||||
import Avatar from './Avatar.svelte'
|
import Avatar from './Avatar.svelte'
|
||||||
|
|
||||||
interface Props {
|
type Item = {
|
||||||
items: {
|
avatar?: string
|
||||||
avatar?: string
|
name: string
|
||||||
name: string
|
instance?: string
|
||||||
instance?: string
|
id: number
|
||||||
id: number
|
url?: string
|
||||||
url: string
|
circle?: boolean
|
||||||
}[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { items }: Props = $props()
|
interface Props {
|
||||||
|
items: Item[]
|
||||||
|
link?: boolean
|
||||||
|
action?: Snippet<[Item]>
|
||||||
|
}
|
||||||
|
|
||||||
|
let { items, link, action }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<CommonList animate={false} class="px-1 py-0.5" size="xs" {items}>
|
<CommonList animate={false} class="px-1 py-0.5" size="xs" {items}>
|
||||||
@@ -23,7 +29,7 @@
|
|||||||
gap="lg"
|
gap="lg"
|
||||||
color="none"
|
color="none"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
href={item.url}
|
href={link ? item.url : undefined}
|
||||||
>
|
>
|
||||||
<div class="flex-none">
|
<div class="flex-none">
|
||||||
<Avatar
|
<Avatar
|
||||||
@@ -31,7 +37,7 @@
|
|||||||
alt={item.name}
|
alt={item.name}
|
||||||
title={item.name}
|
title={item.name}
|
||||||
width={24}
|
width={24}
|
||||||
circle={false}
|
circle={item.circle ?? false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col max-w-full break-words">
|
<div class="flex flex-col max-w-full break-words">
|
||||||
@@ -42,6 +48,10 @@
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{#if action}
|
||||||
|
<div class="flex-1"></div>
|
||||||
|
{@render action(item)}
|
||||||
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</CommonList>
|
</CommonList>
|
||||||
@@ -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>
|
<title>{$t('profile.profile')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4 h-full z-0">
|
<div class="flex flex-row justify-between">
|
||||||
<div class="flex flex-row justify-between">
|
<Tabs
|
||||||
<Tabs
|
routes={[
|
||||||
routes={[
|
{
|
||||||
{
|
href: '/profile/user',
|
||||||
href: '/profile/user',
|
name: $t('routes.profile.submissions'),
|
||||||
name: $t('routes.profile.submissions'),
|
},
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
href: '/profile/settings',
|
href: '/profile/settings',
|
||||||
name: $t('routes.profile.edit'),
|
name: $t('routes.profile.edit'),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
href: '/profile/blocks',
|
href: '/profile/blocks',
|
||||||
name: $t('routes.profile.blocks.title'),
|
name: $t('routes.profile.blocks.title'),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
href: '/profile/password',
|
href: '/profile/password',
|
||||||
name: $t('routes.profile.credentials'),
|
name: $t('routes.profile.credentials'),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Menu class="flex-1" placement="bottom-end">
|
<Menu class="flex-1" placement="bottom-end">
|
||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
{@attach attachment}
|
{@attach attachment}
|
||||||
aria-label={$t('post.actions.more.label')}
|
aria-label={$t('post.actions.more.label')}
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
color="none"
|
color="none"
|
||||||
class="z-0 text-slate-600 dark:text-zinc-500 hover:bg-slate-100 hover:dark:bg-zinc-800"
|
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 />
|
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuButton href="/profile/media" icon={Photo}>
|
<MenuButton href="/profile/media" icon={Photo}>
|
||||||
{$t('routes.profile.media.title')}
|
{$t('routes.profile.media.title')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton href="/profile/voted/up" icon={ArrowUp}>
|
<MenuButton href="/profile/voted/up" icon={ArrowUp}>
|
||||||
{$t('routes.profile.upvoted')}
|
{$t('routes.profile.upvoted')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton href="/profile/voted/down" icon={ArrowDown}>
|
<MenuButton href="/profile/voted/down" icon={ArrowDown}>
|
||||||
{$t('routes.profile.downvoted')}
|
{$t('routes.profile.downvoted')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
|
||||||
{@render children?.()}
|
|
||||||
</div>
|
</div>
|
||||||
|
{@render children?.()}
|
||||||
@@ -9,7 +9,7 @@ export async function load({ fetch }) {
|
|||||||
if (!profile.current.jwt) error(401)
|
if (!profile.current.jwt) error(401)
|
||||||
|
|
||||||
const my_user =
|
const my_user =
|
||||||
// profile.current?.user ??
|
profile.current?.user ??
|
||||||
(await client({ auth: profile.current?.jwt, func: fetch }).getSite())
|
(await client({ auth: profile.current?.jwt, func: fetch }).getSite())
|
||||||
.my_user
|
.my_user
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
page: data.page,
|
page: data.page,
|
||||||
sort: data.sort,
|
sort: data.sort,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
|
limit: data.limit,
|
||||||
}),
|
}),
|
||||||
person_view: { value: data.user.person_view },
|
person_view: { value: data.user.person_view },
|
||||||
moderates: { value: data.user.moderates },
|
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 type { SortType } from '$lib/api/types'
|
||||||
|
import { feed } from '$lib/feature/feeds/feed.svelte.js'
|
||||||
import { getItemPublished } from '$lib/feature/legacy/item'
|
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 page = Number(url.searchParams.get('page')) || 1
|
||||||
const type: 'comments' | 'posts' | 'all' =
|
const type: 'comments' | 'posts' | 'all' =
|
||||||
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
||||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New'
|
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New'
|
||||||
|
|
||||||
const { my_user } = await parent()
|
const myUser = await parent()
|
||||||
|
const feedData = await feed(route.id, (params) =>
|
||||||
const user = await getClient(undefined, fetch).getPersonDetails({
|
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,
|
limit: 20,
|
||||||
page: page,
|
page: page,
|
||||||
username: my_user?.local_user_view.person.name,
|
person_id: myUser.my_user?.local_user_view.person.id,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
})
|
})
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
...(type == 'all' || type == 'posts' ? user.posts : []),
|
...(type == 'all' || type == 'posts' ? feedData.posts : []),
|
||||||
...(type == 'all' || type == 'comments' ? user.comments : []),
|
...(type == 'all' || type == 'comments' ? feedData.comments : []),
|
||||||
]
|
]
|
||||||
|
|
||||||
if (sort == 'TopAll') {
|
if (sort == 'TopAll') {
|
||||||
@@ -40,10 +47,11 @@ export async function load({ url, fetch, parent }) {
|
|||||||
type: type,
|
type: type,
|
||||||
page: page,
|
page: page,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
|
limit: 20,
|
||||||
user: {
|
user: {
|
||||||
submissions: items,
|
submissions: items,
|
||||||
moderates: user.moderates,
|
moderates: feedData.moderates,
|
||||||
person_view: user.person_view,
|
person_view: feedData.person_view,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@ export async function load({ params, url, fetch }) {
|
|||||||
type: type,
|
type: type,
|
||||||
page: page,
|
page: page,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
|
limit: 20,
|
||||||
}),
|
}),
|
||||||
person_view: new ReactiveState(user.person_view),
|
person_view: new ReactiveState(user.person_view),
|
||||||
moderates: new ReactiveState(user.moderates),
|
moderates: new ReactiveState(user.moderates),
|
||||||
|
|||||||
@@ -162,11 +162,26 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={async () => {
|
||||||
blockUser(
|
const res = await blockUser(
|
||||||
isBlocked(profile.current.user!, person.person.id),
|
!isBlocked(profile.current.user!, person.person.id),
|
||||||
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()}
|
{#snippet prefix()}
|
||||||
<Icon mini size="16" src={NoSymbol} />
|
<Icon mini size="16" src={NoSymbol} />
|
||||||
|
|||||||
Reference in new issue
Block a user