refactor: switch posts to barrel export
This commit is contained in:
47 files changed
+424
-528
No files matched your search
@@ -11,8 +11,12 @@
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||
import { site } from '$lib/client/lemmy.svelte'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { inDarkColorScheme, rgbToHex, theme } from '$lib/ui/colors.svelte.js'
|
||||
import { getDefaultColors } from '$lib/ui/presets'
|
||||
import {
|
||||
inDarkColorScheme,
|
||||
rgbToHex,
|
||||
theme,
|
||||
} from '$lib/ui/theme/theme.svelte.js'
|
||||
import { getDefaultColors } from '$lib/ui/theme/presets'
|
||||
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
|
||||
import nProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
||||
import { settings, SSR_ENABLED } from '$lib/settings.svelte.js'
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import { Spinner } from 'mono-svelte'
|
||||
import type { ResolveObjectResponse } from '$lib/client/types'
|
||||
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import { CommunityItem } from '$lib/components/lemmy/community'
|
||||
import { PostItem } from '$lib/components/lemmy/post'
|
||||
|
||||
interface Props {
|
||||
data: {
|
||||
@@ -27,7 +27,7 @@
|
||||
{:else if object.person}
|
||||
<UserItem user={object.person} />
|
||||
{:else if object.post}
|
||||
<Post post={object.post} />
|
||||
<PostItem post={object.post} />
|
||||
{:else if object.comment}
|
||||
<CommentItem comment={object.comment} />
|
||||
{/if}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
import { preventDefault } from 'svelte/legacy'
|
||||
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { client, getClient } from '$lib/client/lemmy.svelte'
|
||||
import type { Instance } from '$lib/client/types'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { getClient } from '$lib/client/lemmy.svelte'
|
||||
import { trycatch } from '$lib/util.svelte.js'
|
||||
import type { Instance } from '$lib/client/types'
|
||||
import { errorMessage } from '$lib/lemmy/error.js'
|
||||
import {
|
||||
Button,
|
||||
FileInput,
|
||||
@@ -40,9 +40,9 @@
|
||||
}),
|
||||
saving = $state(false)
|
||||
|
||||
const moderateInstance = async (instance: string, blocked: boolean) => {
|
||||
async function moderateInstance(instance: string, blocked: boolean) {
|
||||
if (instance == '') return
|
||||
await trycatch(async () => {
|
||||
try {
|
||||
if (
|
||||
!profile.current?.jwt ||
|
||||
!data.instances.value?.blocked ||
|
||||
@@ -53,9 +53,9 @@
|
||||
if (blocked) blockInstance.loading = true
|
||||
else allowInstance.loading = true
|
||||
|
||||
const blockedInstances = data.instances.value.blocked.map(i => i.domain)
|
||||
const blockedInstances = data.instances.value.blocked.map((i) => i.domain)
|
||||
|
||||
const allowedInstances = data.instances.value.allowed.map(i => i.domain)
|
||||
const allowedInstances = data.instances.value.allowed.map((i) => i.domain)
|
||||
|
||||
if (blocked) blockedInstances.push(instance)
|
||||
if (!blocked) allowedInstances.push(instance)
|
||||
@@ -71,32 +71,41 @@
|
||||
data.instances.value = instances.federated_instances
|
||||
|
||||
blockInstance.instance = ''
|
||||
})
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: errorMessage(err as string),
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
|
||||
blockInstance.loading = false
|
||||
allowInstance.loading = false
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
const res = await trycatch(async () => {
|
||||
async function save() {
|
||||
try {
|
||||
if (!profile.current?.jwt || !data.instances.value?.blocked) return
|
||||
|
||||
saving = true
|
||||
|
||||
const blockedInstances = data.instances.value.blocked.map(i => i.domain)
|
||||
const allowedInstances = data.instances.value.allowed?.map(i => i.domain)
|
||||
const blockedInstances = data.instances.value.blocked.map((i) => i.domain)
|
||||
const allowedInstances = data.instances.value.allowed?.map(
|
||||
(i) => i.domain,
|
||||
)
|
||||
|
||||
return await getClient().editSite({
|
||||
await client().editSite({
|
||||
allowed_instances: allowedInstances,
|
||||
blocked_instances: blockedInstances,
|
||||
})
|
||||
})
|
||||
|
||||
if (res) {
|
||||
toast({
|
||||
content: $t('toast.updatedSite'),
|
||||
type: 'success',
|
||||
})
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: errorMessage(err as string),
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
saving = false
|
||||
}
|
||||
@@ -108,7 +117,7 @@
|
||||
|
||||
const reader = new FileReader()
|
||||
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
if (!data.instances.value?.blocked) throw new Error('Missing instance')
|
||||
const content = e.target?.result
|
||||
if (!content) toast({ content: $t('toast.failCSV'), type: 'warning' })
|
||||
@@ -223,7 +232,7 @@
|
||||
|
||||
data.instances.value.blocked =
|
||||
data.instances.value?.blocked.filter(
|
||||
i => i.id != instance.id,
|
||||
(i) => i.id != instance.id,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -307,7 +316,7 @@
|
||||
|
||||
data.instances.value.allowed =
|
||||
data.instances.value?.allowed.filter(
|
||||
i => i.id != instance.id,
|
||||
(i) => i.id != instance.id,
|
||||
)
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
@@ -19,6 +17,7 @@
|
||||
import { Badge, Button, Modal, Note } from 'mono-svelte'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { ArrowRight, ChartBar, Icon, Plus, XMark } from 'svelte-hero-icons'
|
||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import PostForm from '$lib/components/lemmy/post/form/PostForm.svelte'
|
||||
import { PostForm } from '$lib/components/lemmy/post'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||
import { onDestroy } from 'svelte'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { getClient } from '$lib/client/lemmy.svelte'
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import { PostItem } from '$lib/components/lemmy/post'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
@@ -189,7 +189,7 @@
|
||||
{#if item.type == 'comment'}
|
||||
<CommentItem comment={item.item} class="p-0!" />
|
||||
{:else if item.type == 'post'}
|
||||
<Post hideCommunity post={item.item} class="p-0!" />
|
||||
<PostItem post={item.item} />
|
||||
{:else if item.type == 'message'}
|
||||
<PrivateMessage
|
||||
message={{
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
import { client } from '$lib/client/lemmy.svelte'
|
||||
import Spinner from 'mono-svelte/loader/Spinner.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { postLink } from '$lib/components/lemmy/post/helpers'
|
||||
import { CommunityLink } from '$lib/components/lemmy/community'
|
||||
import { postLink } from '$lib/components/lemmy/post'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import PostActions from '$lib/components/lemmy/post/actions/PostActions.svelte'
|
||||
import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import PostMeta, {
|
||||
parseTags,
|
||||
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||
@@ -20,7 +13,6 @@
|
||||
import { postFeeds } from '$lib/lemmy/postfeed.svelte'
|
||||
import { ReactiveState } from '$lib/util.svelte'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { isImage } from '$lib/ui/image.js'
|
||||
import { Button, toast } from 'mono-svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import {
|
||||
@@ -32,6 +24,7 @@
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import CommentProvider from './CommentProvider.svelte'
|
||||
import { mediaType, parseTags, Post, PostActions, postLink, PostMedia, PostMeta } from '$lib/components/lemmy/post'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
@@ -111,7 +104,7 @@
|
||||
/>
|
||||
{/if}
|
||||
<meta property="og:url" content={page.url.toString()} />
|
||||
{#if isImage(data.post.value.post_view.post.url)}
|
||||
{#if mediaType(data.post.value.post_view.post.url) == 'image'}
|
||||
<meta property="og:image" content={data.post.value.post_view.post.url} />
|
||||
<meta
|
||||
property="twitter:card"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { browser } from '$app/environment'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state'
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import PostItem from '$lib/components/lemmy/post/PostItem.svelte'
|
||||
import Fixate from '$lib/components/ui/generic/Fixate.svelte'
|
||||
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
@@ -20,6 +19,7 @@
|
||||
Icon,
|
||||
PencilSquare,
|
||||
} from 'svelte-hero-icons'
|
||||
import { PostItem } from '$lib/components/lemmy/post'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import { CommunityItem } from '$lib/components/lemmy/community'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import PostItem from '$lib/components/lemmy/post/PostItem.svelte'
|
||||
import { PostItem } from '$lib/components/lemmy/post'
|
||||
import UserItem from '$lib/components/lemmy/user/UserItem.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { theme as themeData } from '$lib/ui/colors.svelte'
|
||||
import { getDefaultColors } from '$lib/ui/presets'
|
||||
import { theme as themeData } from '$lib/ui/theme/theme.svelte'
|
||||
import { getDefaultColors } from '$lib/ui/theme/presets'
|
||||
import {
|
||||
Button,
|
||||
Material,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { hexToRgb } from '$lib/ui/colors.svelte'
|
||||
import { hexToRgb } from '$lib/ui/theme/theme.svelte'
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { theme as themeData, type Theme } from '$lib/ui/colors.svelte'
|
||||
import { theme as themeData, type Theme } from '$lib/ui/theme/theme.svelte'
|
||||
import { action, Button, Material, modal, TextInput } from 'mono-svelte'
|
||||
import { CheckCircle, Icon, Trash } from 'svelte-hero-icons'
|
||||
|
||||
|
||||
@@ -1,50 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import PostItem from '$lib/components/lemmy/post/PostItem.svelte'
|
||||
import { PostItem } from '$lib/components/lemmy/post'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
||||
import { CommonList, Header, Pageination } from '$lib/components/ui/layout'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { client, getClient } from '$lib/client/lemmy.svelte'
|
||||
import { communityLink } from '$lib/lemmy/generic.js'
|
||||
import { isCommentView } from '$lib/lemmy/item.js'
|
||||
import { isBlocked } from '$lib/lemmy/user.js'
|
||||
import {
|
||||
Button,
|
||||
Menu,
|
||||
MenuButton,
|
||||
Modal,
|
||||
Option,
|
||||
removeToast,
|
||||
Select,
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
import {
|
||||
AdjustmentsHorizontal,
|
||||
AtSymbol,
|
||||
EllipsisHorizontal,
|
||||
Envelope,
|
||||
Fire,
|
||||
Icon,
|
||||
Newspaper,
|
||||
NoSymbol,
|
||||
PencilSquare,
|
||||
ShieldExclamation,
|
||||
} from 'svelte-hero-icons'
|
||||
import { Option, Select } from 'mono-svelte'
|
||||
import { AdjustmentsHorizontal, Icon, PencilSquare } from 'svelte-hero-icons'
|
||||
import type { PageData } from './$types'
|
||||
import UserActions from './UserActions.svelte'
|
||||
|
||||
interface Props {
|
||||
data: PageData
|
||||
@@ -54,103 +27,12 @@
|
||||
let { data, inline = false }: Props = $props()
|
||||
|
||||
let sortForm = $state<HTMLFormElement>()
|
||||
|
||||
async function blockUser(block: number) {
|
||||
if (!profile.current?.user || !profile.current?.jwt)
|
||||
throw new Error('Unauthenticated')
|
||||
|
||||
try {
|
||||
const blocked = isBlocked(profile.current.user, block)
|
||||
|
||||
await getClient().blockPerson({
|
||||
block: !blocked,
|
||||
person_id: block,
|
||||
})
|
||||
|
||||
if (blocked) {
|
||||
const index = profile.current.user.person_blocks
|
||||
.map(p => p.target.id)
|
||||
.indexOf(block)
|
||||
profile.current.user.person_blocks.splice(index, 1)
|
||||
}
|
||||
|
||||
toast({
|
||||
content: blocked ? $t('toast.unblockUser') : $t('toast.blockUser'),
|
||||
type: 'success',
|
||||
})
|
||||
|
||||
goto(page.url, {
|
||||
invalidateAll: true,
|
||||
})
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: err as string,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let purgingUser = $state(false)
|
||||
let purgeEnabled = $state(false)
|
||||
$effect(() => {
|
||||
if (purgingUser) {
|
||||
purgeEnabled = false
|
||||
setTimeout(() => {
|
||||
purgeEnabled = true
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
|
||||
async function purgeUser() {
|
||||
purgingUser = false
|
||||
const purgeToast = toast({ content: '', loading: true })
|
||||
|
||||
try {
|
||||
await client().purgePerson({
|
||||
person_id: data.person_view.value.person.id,
|
||||
})
|
||||
removeToast(purgeToast)
|
||||
toast({ content: $t('toast.purgeUser'), type: 'success' })
|
||||
} catch (e) {
|
||||
toast({ content: e as string, type: 'error' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.person_view.value.person.name}</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if purgingUser}
|
||||
<Modal bind:open={purgingUser}>
|
||||
{#snippet customTitle()}
|
||||
Purging User
|
||||
{/snippet}
|
||||
<p>
|
||||
Purging user <span class="font-bold">
|
||||
{data.person_view.value.person.name}
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
Are you sure you want to do this? (The button will enable in 3 seconds.)
|
||||
</p>
|
||||
<div class="flex flex-row gap-2">
|
||||
<Button size="lg" onclick={() => (purgingUser = false)} class="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
size="lg"
|
||||
color="danger"
|
||||
onclick={purgeUser}
|
||||
disabled={!purgeEnabled}
|
||||
class="flex-1"
|
||||
>
|
||||
Purge
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full">
|
||||
{#if !inline}
|
||||
<Header pageHeader class="tracking-normal!">
|
||||
@@ -201,7 +83,7 @@
|
||||
/>
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={data.moderates.value.map(m => ({
|
||||
items={data.moderates.value.map((m) => ({
|
||||
id: m.community.id,
|
||||
name: m.community.title,
|
||||
url: communityLink(m.community),
|
||||
@@ -212,97 +94,7 @@
|
||||
</Expandable>
|
||||
{/if}
|
||||
{#snippet actions()}
|
||||
{#if profile.current?.user && profile.current.jwt && data.person_view.value.person.id != profile.current.user.local_user_view.person.id}
|
||||
<div class="flex items-center gap-2 w-full flex-wrap">
|
||||
<Button
|
||||
size="sm"
|
||||
rounding="pill"
|
||||
color="primary"
|
||||
href="/inbox/messages/{data.person_view.value.person.id}"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon micro size="16" src={Envelope} />
|
||||
{/snippet}
|
||||
{$t('content.message')}
|
||||
</Button>
|
||||
{#if data.person_view.value.person.matrix_user_id}
|
||||
<Button
|
||||
size="sm"
|
||||
rounding="pill"
|
||||
color="secondary"
|
||||
href="https://matrix.to/#/{data.person_view.value.person
|
||||
.matrix_user_id}"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon solid size="16" src={AtSymbol} />
|
||||
{/snippet}
|
||||
{$t('form.profile.matrix')}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isAdmin(profile.current?.user)}
|
||||
<Menu class="ml-auto" placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button {@attach attachment} size="sm" rounding="pill">
|
||||
<ShieldIcon width={16} filled />
|
||||
{$t('moderation.label')}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
href="/modlog?user={data.person_view.value.person.id}"
|
||||
color="success-subtle"
|
||||
>
|
||||
<Icon src={Newspaper} size="16" micro />
|
||||
{$t('moderation.modlog.user')}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() =>
|
||||
ban(
|
||||
data.person_view.value.person.banned,
|
||||
data.person_view.value.person,
|
||||
)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={ShieldExclamation} />
|
||||
{/snippet}
|
||||
{data.person_view.value.person.banned ? 'Unban' : 'Ban'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => (purgingUser = !purgingUser)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={Fire} />
|
||||
{/snippet}
|
||||
Purge
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button {@attach attachment} size="custom" class="h-8 w-8" rounding="pill">
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => blockUser(data.person_view.value.person.id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
{/snippet}
|
||||
{isBlocked(
|
||||
profile.current.user,
|
||||
data.person_view.value.person.id,
|
||||
)
|
||||
? 'Unblock'
|
||||
: 'Block'}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</div>
|
||||
{/if}
|
||||
<UserActions person={data.person_view.value} />
|
||||
{/snippet}
|
||||
</EntityHeader>
|
||||
</div>
|
||||
@@ -358,6 +150,6 @@
|
||||
{/if}
|
||||
<Pageination
|
||||
bind:page={data.filters.value.page}
|
||||
href={page => `?page=${page}`}
|
||||
href={(page) => `?page=${page}`}
|
||||
/>
|
||||
</div>
|
||||
@@ -0,0 +1,145 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { client } from '$lib/client/lemmy.svelte'
|
||||
import type { PersonView } from '$lib/client/types'
|
||||
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { blockUser, isBlocked } from '$lib/lemmy/user'
|
||||
import { Button, Menu, MenuButton, Modal, removeToast, toast } from 'mono-svelte'
|
||||
import { AtSymbol, EllipsisHorizontal, Envelope, Fire, Icon, Newspaper, NoSymbol, ShieldExclamation } from 'svelte-hero-icons'
|
||||
|
||||
let { person }: { person: PersonView } = $props()
|
||||
|
||||
let purgingUser = $state(false)
|
||||
|
||||
async function purgeUser() {
|
||||
purgingUser = false
|
||||
const purgeToast = toast({ content: '', loading: true })
|
||||
|
||||
try {
|
||||
await client().purgePerson({
|
||||
person_id: person.person.id,
|
||||
})
|
||||
removeToast(purgeToast)
|
||||
toast({ content: $t('toast.purgeUser'), type: 'success' })
|
||||
} catch (e) {
|
||||
toast({ content: e as string, type: 'error' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
{#if purgingUser}
|
||||
<Modal bind:open={purgingUser}>
|
||||
{#snippet customTitle()}
|
||||
Purging User
|
||||
{/snippet}
|
||||
<p>
|
||||
Purging user <span class="font-bold">
|
||||
{person.person.name}
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
Are you sure you want to do this?
|
||||
</p>
|
||||
<div class="flex flex-row gap-2">
|
||||
<Button size="lg" onclick={() => (purgingUser = false)} class="flex-1">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
size="lg"
|
||||
color="danger"
|
||||
onclick={purgeUser}
|
||||
class="flex-1"
|
||||
>
|
||||
Purge
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
{#if profile.current?.user && profile.current.jwt && person.person.id != profile.current.user.local_user_view.person.id}
|
||||
<div class="flex items-center gap-2 w-full flex-wrap">
|
||||
<Button
|
||||
size="sm"
|
||||
rounding="pill"
|
||||
color="primary"
|
||||
href="/inbox/messages/{person.person.id}"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon micro size="16" src={Envelope} />
|
||||
{/snippet}
|
||||
{$t('content.message')}
|
||||
</Button>
|
||||
{#if person.person.matrix_user_id}
|
||||
<Button
|
||||
size="sm"
|
||||
rounding="pill"
|
||||
color="secondary"
|
||||
href="https://matrix.to/#/{person.person.matrix_user_id}"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon solid size="16" src={AtSymbol} />
|
||||
{/snippet}
|
||||
{$t('form.profile.matrix')}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isAdmin(profile.current?.user)}
|
||||
<Menu class="ml-auto" placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button {@attach attachment} size="sm" rounding="pill">
|
||||
<ShieldIcon width={16} filled />
|
||||
{$t('moderation.label')}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
href="/modlog?user={person.person.id}"
|
||||
color="success-subtle"
|
||||
>
|
||||
<Icon src={Newspaper} size="16" micro />
|
||||
{$t('moderation.modlog.user')}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => ban(person.person.banned, person.person)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={ShieldExclamation} />
|
||||
{/snippet}
|
||||
{person.person.banned ? 'Unban' : 'Ban'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => (purgingUser = !purgingUser)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={Fire} />
|
||||
{/snippet}
|
||||
Purge
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
<Menu placement="bottom-end">
|
||||
{#snippet target(attachment)}
|
||||
<Button {@attach attachment} size="custom" class="h-8 w-8" rounding="pill">
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={() => blockUser(isBlocked(profile.current.user!, person.person.id), person.person.id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
{/snippet}
|
||||
{isBlocked(profile.current.user, person.person.id)
|
||||
? 'Unblock'
|
||||
: 'Block'}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||
import { isImage, isVideo } from '$lib/util.svelte'
|
||||
import { TextInput } from 'mono-svelte'
|
||||
|
||||
let imageInput = $state('')
|
||||
|
||||
Reference in new issue
Block a user