impr: replace amMod, amModOfAny, isAdmin, with profile class getters
This commit is contained in:
18 files changed
+89
-89
No files matched your search
@@ -3,7 +3,6 @@ import { env } from '$env/dynamic/public'
|
|||||||
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/api/base'
|
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/api/base'
|
||||||
import { client, getClient, site } from '$lib/api/client.svelte'
|
import { client, getClient, site } from '$lib/api/client.svelte'
|
||||||
import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types'
|
import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types'
|
||||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import { publishedToDate } from '$lib/ui/util/date'
|
import { publishedToDate } from '$lib/ui/util/date'
|
||||||
import { toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
@@ -207,11 +206,7 @@ class Profile {
|
|||||||
const { user, jwt } = profile.current
|
const { user, jwt } = profile.current
|
||||||
if (!user || !jwt) throw new Error('checkInbox() called with invalid user')
|
if (!user || !jwt) throw new Error('checkInbox() called with invalid user')
|
||||||
|
|
||||||
const notifs = await getNotificationCount(
|
const notifs = await getNotificationCount(jwt, this.isMod(), this.isAdmin)
|
||||||
jwt,
|
|
||||||
amModOfAny(user) ?? false,
|
|
||||||
user ? isAdmin(user) : false,
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inbox: notifs.unreads,
|
inbox: notifs.unreads,
|
||||||
@@ -268,6 +263,26 @@ class Profile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMod(community?: Community) {
|
||||||
|
if (community)
|
||||||
|
return (
|
||||||
|
(this.#current.user?.moderates.some(
|
||||||
|
(i) => i.community.id == community.id,
|
||||||
|
) ||
|
||||||
|
(community.local && this.isAdmin)) ??
|
||||||
|
false
|
||||||
|
)
|
||||||
|
else return (this.#current.user?.moderates.length ?? 0) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get isAdmin() {
|
||||||
|
return (
|
||||||
|
site.data?.admins.some(
|
||||||
|
(i) => i.person.id == this.#current.user?.local_user_view.person.id,
|
||||||
|
) ?? false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
mainEffect = $effect.root(() => {
|
mainEffect = $effect.root(() => {
|
||||||
// Sync with localStorage
|
// Sync with localStorage
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
Flag,
|
Flag,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
Share,
|
Share,
|
||||||
|
ShieldCheck,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import { deleteItem, save } from '../legacy/contentview'
|
import { deleteItem, save } from '../legacy/contentview'
|
||||||
import CommentModerationMenu from '../moderation/CommentModerationMenu.svelte'
|
import CommentModerationMenu from '../moderation/CommentModerationMenu.svelte'
|
||||||
import { amMod, isAdmin, report } from '../moderation/moderation'
|
import { report } from '../moderation/moderation'
|
||||||
import CommentVote from './CommentVote.svelte'
|
import CommentVote from './CommentVote.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'flex flex-row items-center gap-0.5 h-7 w-full',
|
'flex flex-row items-center gap-0.5 w-full',
|
||||||
settings.posts.reverseActions && 'flex-row-reverse',
|
settings.posts.reverseActions && 'flex-row-reverse',
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@@ -57,8 +58,20 @@
|
|||||||
>
|
>
|
||||||
{$t('comment.reply')}
|
{$t('comment.reply')}
|
||||||
</Button>
|
</Button>
|
||||||
{#if profile.current?.user && (amMod(profile.current?.user, comment.community) || isAdmin(profile.current.user))}
|
{#if profile.current?.user && (profile.isMod(comment.community) || profile.isAdmin)}
|
||||||
<CommentModerationMenu bind:item={comment} />
|
<CommentModerationMenu bind:item={comment}>
|
||||||
|
{#snippet target(attachment)}
|
||||||
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
|
class="dark:text-zinc-400 text-slate-600"
|
||||||
|
color="tertiary"
|
||||||
|
size="square-md"
|
||||||
|
rounding="pill"
|
||||||
|
icon={ShieldCheck}
|
||||||
|
aria-label={$t('moderation.label')}
|
||||||
|
/>
|
||||||
|
{/snippet}
|
||||||
|
</CommentModerationMenu>
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { site } from '$lib/api/client.svelte'
|
import { site } from '$lib/api/client.svelte'
|
||||||
|
import type { Comment } from '$lib/api/types'
|
||||||
import { profile } from '$lib/app/auth.svelte'
|
import { profile } from '$lib/app/auth.svelte'
|
||||||
import { errorMessage } from '$lib/app/error'
|
import { errorMessage } from '$lib/app/error'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
Tag,
|
Tag,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import { amMod, isAdmin } from '../moderation/moderation'
|
|
||||||
import { addSubscription } from '../user'
|
import { addSubscription } from '../user'
|
||||||
import CommunityFlair from './CommunityFlair.svelte'
|
import CommunityFlair from './CommunityFlair.svelte'
|
||||||
|
|
||||||
@@ -219,7 +218,7 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.user && amMod(profile.current.user, community_view.community)}
|
{#if profile.isMod(community_view.community)}
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
@@ -242,7 +241,7 @@
|
|||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
{#if profile.current.user && amMod(profile.current.user, community_view.community)}
|
{#if profile.isMod(community_view.community)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="success-subtle"
|
color="success-subtle"
|
||||||
href="/moderation?community={community_view.community.id}"
|
href="/moderation?community={community_view.community.id}"
|
||||||
@@ -272,7 +271,7 @@
|
|||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
Tag,
|
Tag,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import Subscribe from '../../../routes/communities/Subscribe.svelte'
|
import Subscribe from '../../../routes/communities/Subscribe.svelte'
|
||||||
import { amMod, isAdmin } from '../moderation/moderation'
|
|
||||||
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
||||||
import CommunityFlair from './CommunityFlair.svelte'
|
import CommunityFlair from './CommunityFlair.svelte'
|
||||||
|
|
||||||
@@ -219,7 +218,7 @@
|
|||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current.user && amMod(profile.current.user, community)}
|
{#if profile.isMod(community)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="success-subtle"
|
color="success-subtle"
|
||||||
href="/moderation?community={community.id}"
|
href="/moderation?community={community.id}"
|
||||||
@@ -239,17 +238,15 @@
|
|||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current?.user}
|
<MenuButton
|
||||||
<MenuButton
|
color="danger-subtle"
|
||||||
color="danger-subtle"
|
size="lg"
|
||||||
size="lg"
|
onclick={() => blockInstance(community.instance_id)}
|
||||||
onclick={() => blockInstance(community.instance_id)}
|
icon={BuildingOffice2}
|
||||||
icon={BuildingOffice2}
|
>
|
||||||
>
|
{$t('cards.community.blockInstance')}
|
||||||
{$t('cards.community.blockInstance')}
|
</MenuButton>
|
||||||
</MenuButton>
|
{#if profile.isAdmin}
|
||||||
{/if}
|
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
Newspaper,
|
Newspaper,
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import { amModOfAny } from '../moderation/moderation'
|
|
||||||
|
|
||||||
interface Props extends SelectProps<string> {
|
interface Props extends SelectProps<string> {
|
||||||
selected: string
|
selected: string
|
||||||
@@ -64,11 +63,7 @@
|
|||||||
>
|
>
|
||||||
{$t('filter.location.subscribed')}
|
{$t('filter.location.subscribed')}
|
||||||
</Option>
|
</Option>
|
||||||
<Option
|
<Option value="ModeratorView" disabled={!profile.isMod()} icon={ShieldCheck}>
|
||||||
value="ModeratorView"
|
|
||||||
disabled={!profile.current?.jwt || !amModOfAny(profile.current?.user)}
|
|
||||||
icon={ShieldCheck}
|
|
||||||
>
|
|
||||||
{$t('filter.location.moderator')}
|
{$t('filter.location.moderator')}
|
||||||
</Option>
|
</Option>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
import type { CommentView } from '$lib/api/types'
|
import type { CommentView } from '$lib/api/types'
|
||||||
import { profile } from '$lib/app/auth.svelte'
|
import { profile } from '$lib/app/auth.svelte'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
import {
|
import {
|
||||||
ArrowsUpDown,
|
ArrowsUpDown,
|
||||||
Fire,
|
Fire,
|
||||||
@@ -12,32 +13,22 @@
|
|||||||
ShieldExclamation,
|
ShieldExclamation,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import { isCommentView } from '../legacy/item'
|
import { isCommentView } from '../legacy/item'
|
||||||
import { amMod, ban, feature, isAdmin, remove, viewVotes } from './moderation'
|
import { ban, feature, remove, viewVotes } from './moderation'
|
||||||
import ShieldIcon from './ShieldIcon.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: CommentView
|
item: CommentView
|
||||||
|
target: Snippet<[Attachment]>
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item = $bindable(), ...rest }: Props = $props()
|
let { item = $bindable(), target, ...rest }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom" class="top-0 h-[26px] w-[26px] ">
|
<Menu {...rest} placement="bottom" {target}>
|
||||||
{#snippet target(attachment)}
|
{#if profile.isMod(item.community) || profile.isAdmin}
|
||||||
<Button
|
<MenuDivider hidden>
|
||||||
{@attach attachment}
|
{#if !item.community.local && !profile.isMod(item.community)}
|
||||||
class="w-[26px] h-[26px] hover:text-green-500! dark:text-zinc-400 text-slate-600"
|
|
||||||
size="square-md"
|
|
||||||
color="tertiary"
|
|
||||||
{...rest}
|
|
||||||
>
|
|
||||||
<ShieldIcon filled width={14} />
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
|
|
||||||
<MenuDivider showLabel>
|
|
||||||
{#if !item.community.local && !amMod(profile.current.user, item.community)}
|
|
||||||
{$t('moderation.labelInstanceOnly')}
|
{$t('moderation.labelInstanceOnly')}
|
||||||
{:else}
|
{:else}
|
||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
@@ -98,7 +89,7 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import type { Attachment } from 'svelte/attachments'
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import { isCommentView, isPostView } from '../legacy/item'
|
import { isCommentView, isPostView } from '../legacy/item'
|
||||||
import { amMod, ban, isAdmin, remove, viewVotes } from './moderation'
|
import { ban, remove, viewVotes } from './moderation'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: PostView | CommentView
|
item: PostView | CommentView
|
||||||
@@ -79,9 +79,9 @@
|
|||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
{@render passedTarget(attachment, acting)}
|
{@render passedTarget(attachment, acting)}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
|
{#if profile.isMod(item.community) || profile.isAdmin}
|
||||||
<MenuDivider showLabel>
|
<MenuDivider showLabel>
|
||||||
{#if !item.community.local && !amMod(profile.current.user, item.community)}
|
{#if !item.community.local && !profile.isMod(item.community)}
|
||||||
{$t('moderation.labelInstanceOnly')}
|
{$t('moderation.labelInstanceOnly')}
|
||||||
{:else}
|
{:else}
|
||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
? $t('moderation.unfeature')
|
? $t('moderation.unfeature')
|
||||||
: $t('moderation.feature')}
|
: $t('moderation.feature')}
|
||||||
</span>
|
</span>
|
||||||
{#if isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
|
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
{$t('moderation.votes')}
|
{$t('moderation.votes')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="success-subtle"
|
color="success-subtle"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
import Comment from '../comment/Comment.svelte'
|
import Comment from '../comment/Comment.svelte'
|
||||||
import { isCommentView, isPostView } from '../legacy/item'
|
import { isCommentView, isPostView } from '../legacy/item'
|
||||||
import { Post } from '../post'
|
import { Post } from '../post'
|
||||||
import { amMod, isAdmin, removalTemplate } from './moderation'
|
import { removalTemplate } from './moderation'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
bind:value={reason}
|
bind:value={reason}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if !removed && profile.current?.user && (amMod(profile.current.user, item.community) || (isAdmin(profile.current.user) && item.community.local))}
|
{#if !removed}
|
||||||
<Switch bind:checked={commentReason}>
|
<Switch bind:checked={commentReason}>
|
||||||
{$t('moderation.removeSubmission.withReason')}
|
{$t('moderation.removeSubmission.withReason')}
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { client } from '$lib/api/client.svelte'
|
import { client } from '$lib/api/client.svelte'
|
||||||
import type {
|
import type {
|
||||||
|
Comment,
|
||||||
CommentView,
|
CommentView,
|
||||||
Community,
|
Community,
|
||||||
MyUserInfo,
|
|
||||||
Person,
|
Person,
|
||||||
PostView,
|
PostView,
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
@@ -104,15 +104,6 @@ export async function viewVotes(item: PostView | CommentView) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const amMod = (me: MyUserInfo, community: Community) =>
|
|
||||||
me.moderates.map((c) => c.community.id).includes(community.id) ||
|
|
||||||
(community.local && isAdmin(me))
|
|
||||||
|
|
||||||
export const amModOfAny = (me?: MyUserInfo) =>
|
|
||||||
me && (me.moderates.length > 0 || isAdmin(me))
|
|
||||||
|
|
||||||
export const isAdmin = (me: MyUserInfo) => me.local_user_view.person.admin
|
|
||||||
|
|
||||||
export const removalTemplate = (
|
export const removalTemplate = (
|
||||||
input: string,
|
input: string,
|
||||||
content: {
|
content: {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import { settings, type View } from '$lib/app/settings.svelte'
|
import { settings, type View } from '$lib/app/settings.svelte'
|
||||||
import { save } from '$lib/feature/legacy/contentview'
|
import { save } from '$lib/feature/legacy/contentview'
|
||||||
import { amMod, isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import { publishedToDate } from '$lib/ui/util/date'
|
import { publishedToDate } from '$lib/ui/util/date'
|
||||||
import FormattedNumber from '$lib/ui/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/ui/util/FormattedNumber.svelte'
|
||||||
import { Button, Menu, Modal, Spinner } from 'mono-svelte'
|
import { Button, Menu, Modal, Spinner } from 'mono-svelte'
|
||||||
@@ -133,7 +132,7 @@
|
|||||||
icon={BugAnt}
|
icon={BugAnt}
|
||||||
></Button>
|
></Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
|
{#if profile.isMod(post.community) || profile.isAdmin}
|
||||||
{#await import('$lib/feature/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
{#await import('$lib/feature/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
||||||
<ModerationMenu bind:item={post}>
|
<ModerationMenu bind:item={post}>
|
||||||
{#snippet target(attachment, acting)}
|
{#snippet target(attachment, acting)}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import { notifications, profile } from '$lib/app/auth.svelte'
|
import { notifications, profile } from '$lib/app/auth.svelte'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
|
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
|
||||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import { Menu, Spinner } from 'mono-svelte'
|
import { Menu, Spinner } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
Bars3,
|
Bars3,
|
||||||
@@ -71,7 +70,7 @@
|
|||||||
</NavButton>
|
</NavButton>
|
||||||
<div class="hidden md:block md:flex-1"></div>
|
<div class="hidden md:block md:flex-1"></div>
|
||||||
<div class="sr-only md:not-sr-only md:contents">
|
<div class="sr-only md:not-sr-only md:contents">
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/admin"
|
href="/admin"
|
||||||
label={$t('nav.admin')}
|
label={$t('nav.admin')}
|
||||||
@@ -80,7 +79,7 @@
|
|||||||
isSelectedFilter={(path) => path.startsWith('/admin')}
|
isSelectedFilter={(path) => path.startsWith('/admin')}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if amModOfAny(profile.current?.user)}
|
{#if profile.isMod()}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/moderation"
|
href="/moderation"
|
||||||
label={$t('nav.moderation')}
|
label={$t('nav.moderation')}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
import { settings } from '$lib/app/settings.svelte'
|
import { settings } from '$lib/app/settings.svelte'
|
||||||
import { theme } from '$lib/app/theme/theme.svelte'
|
import { theme } from '$lib/app/theme/theme.svelte'
|
||||||
import InstanceCard from '$lib/feature/instance/InstanceCard.svelte'
|
import InstanceCard from '$lib/feature/instance/InstanceCard.svelte'
|
||||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
@@ -70,7 +69,7 @@
|
|||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if amModOfAny(profile.current.user)}
|
{#if profile.isMod()}
|
||||||
<MenuButton href="/moderation" icon={ShieldCheck}>
|
<MenuButton href="/moderation" icon={ShieldCheck}>
|
||||||
{$t('routes.moderation.feed')}
|
{$t('routes.moderation.feed')}
|
||||||
{#snippet suffix()}
|
{#snippet suffix()}
|
||||||
@@ -78,7 +77,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current.user && isAdmin(profile.current.user)}
|
{#if profile.isAdmin}
|
||||||
<MenuButton href="/admin/applications" icon={ServerStack}>
|
<MenuButton href="/admin/applications" icon={ServerStack}>
|
||||||
{$t('routes.admin.applications.title')}
|
{$t('routes.admin.applications.title')}
|
||||||
{#snippet suffix()}
|
{#snippet suffix()}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { settings } from '$lib/app/settings.svelte'
|
|||||||
import { theme, type ThemeData } from '$lib/app/theme/theme.svelte'
|
import { theme, type ThemeData } from '$lib/app/theme/theme.svelte'
|
||||||
import { fullCommunityName } from '$lib/app/util.svelte'
|
import { fullCommunityName } from '$lib/app/util.svelte'
|
||||||
import type { ResumableItem } from '$lib/feature/legacy/item'
|
import type { ResumableItem } from '$lib/feature/legacy/item'
|
||||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import {
|
import {
|
||||||
ArrowRightOnRectangle,
|
ArrowRightOnRectangle,
|
||||||
ArrowTrendingDown,
|
ArrowTrendingDown,
|
||||||
@@ -92,7 +91,7 @@ export function getGroups(
|
|||||||
name: t.get('nav.communities'),
|
name: t.get('nav.communities'),
|
||||||
icon: GlobeAlt,
|
icon: GlobeAlt,
|
||||||
},
|
},
|
||||||
...(amModOfAny(profile.user)
|
...(currentProfile.isMod()
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
href: '/moderation',
|
href: '/moderation',
|
||||||
@@ -101,7 +100,7 @@ export function getGroups(
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(profile.user && isAdmin(profile.user)
|
...(currentProfile.isAdmin
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
href: '/admin',
|
href: '/admin',
|
||||||
|
|||||||
@@ -3,12 +3,16 @@
|
|||||||
|
|
||||||
let {
|
let {
|
||||||
showLabel = false,
|
showLabel = false,
|
||||||
|
hidden = false,
|
||||||
children,
|
children,
|
||||||
}: { showLabel?: boolean; children: Snippet } = $props()
|
}: { showLabel?: boolean; hidden?: boolean; children: Snippet } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium mx-3 my-1.5 flex items-center gap-1"
|
class={[
|
||||||
|
'text-slate-800 dark:text-zinc-200 text-xs font-medium mx-3 my-1.5 flex items-center gap-1',
|
||||||
|
hidden && 'sr-only',
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<div class={[!showLabel && 'sr-only']}>{@render children?.()}</div>
|
<div class={[!showLabel && 'sr-only']}>{@render children?.()}</div>
|
||||||
<hr
|
<hr
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { getClient } from '$lib/api/client.svelte'
|
|||||||
import { profile } from '$lib/app/auth.svelte'
|
import { profile } from '$lib/app/auth.svelte'
|
||||||
import { ReactiveState } from '$lib/app/util.svelte'
|
import { ReactiveState } from '$lib/app/util.svelte'
|
||||||
import { isCommentView, isPostView } from '$lib/feature/legacy/item'
|
import { isCommentView, isPostView } from '$lib/feature/legacy/item'
|
||||||
import { isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import {
|
import {
|
||||||
generalizeCommentReport,
|
generalizeCommentReport,
|
||||||
generalizePostReport,
|
generalizePostReport,
|
||||||
@@ -30,7 +29,7 @@ export async function load({ url, fetch }) {
|
|||||||
community_id: community,
|
community_id: community,
|
||||||
}
|
}
|
||||||
|
|
||||||
const admin = profile.current?.user ? isAdmin(profile!.current.user!) : false
|
const admin = profile.isAdmin
|
||||||
|
|
||||||
const [posts, comments, messages] = await Promise.all([
|
const [posts, comments, messages] = await Promise.all([
|
||||||
client.listPostReports({
|
client.listPostReports({
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
import { settings } from '$lib/app/settings.svelte'
|
import { settings } from '$lib/app/settings.svelte'
|
||||||
import { searchParam } from '$lib/app/util.svelte'
|
import { searchParam } from '$lib/app/util.svelte'
|
||||||
import CommunityLink from '$lib/feature/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/feature/community/CommunityLink.svelte'
|
||||||
import { isAdmin } from '$lib/feature/moderation/moderation'
|
|
||||||
import { postLink } from '$lib/feature/post'
|
import { postLink } from '$lib/feature/post'
|
||||||
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
|
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
|
||||||
import UserLink from '$lib/feature/user/UserLink.svelte'
|
import UserLink from '$lib/feature/user/UserLink.svelte'
|
||||||
@@ -194,7 +193,7 @@
|
|||||||
onselect={(e) =>
|
onselect={(e) =>
|
||||||
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
||||||
/>
|
/>
|
||||||
{#if profile.current?.user && isAdmin(profile.current?.user)}
|
{#if profile.isAdmin}
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
placeholder="Filter by moderator"
|
placeholder="Filter by moderator"
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import type { PersonView } from '$lib/api/types'
|
import type { PersonView } from '$lib/api/types'
|
||||||
import { profile } from '$lib/app/auth.svelte'
|
import { profile } from '$lib/app/auth.svelte'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
import { ban, isAdmin } from '$lib/feature/moderation/moderation'
|
import { ban } from '$lib/feature/moderation/moderation'
|
||||||
import { blockUser, isBlocked } from '$lib/feature/user'
|
import { blockUser, isBlocked } from '$lib/feature/user'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
{$t('form.profile.matrix')}
|
{$t('form.profile.matrix')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if isAdmin(profile.current?.user)}
|
{#if profile.isAdmin}
|
||||||
<Menu class="ml-auto" placement="bottom-end">
|
<Menu class="ml-auto" placement="bottom-end">
|
||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in new issue
Block a user