This commit is contained in:
Xyphyn committed 2023-07-28 10:35:23 -07:00
1 parent 0d98986871
commit 74fd7714ce
3 files changed
+14 -6

No files matched your search

@@ -70,7 +70,7 @@
<Icon src={ArrowUturnLeft} width={14} height={14} mini />
<span class="text-xs">Reply</span>
</Button>
{#if $user && isMod($user, comment.community.id)}
{#if $user && isMod($user, comment.community)}
<CommentModerationMenu item={comment} />
{/if}
<Menu
@@ -1,4 +1,10 @@
import type { CommentView, MyUserInfo, PostView } from 'lemmy-js-client'
import type {
CommentView,
Community,
CommunityView,
MyUserInfo,
PostView,
} from 'lemmy-js-client'
import { writable } from 'svelte/store'
interface Modals {
@@ -43,9 +49,11 @@ export function remove(item: PostView | CommentView) {
}))
}
export const isMod = (me: MyUserInfo, community: number) =>
me.moderates.map((c) => c.community.id).includes(community)
export const isMod = (me: MyUserInfo, community: Community) =>
me.moderates.map((c) => c.community.id).includes(community.id) ||
(community.local && isAdmin(me))
export const isModOfAny = (me?: MyUserInfo) => me && me.moderates.length > 0
export const isModOfAny = (me?: MyUserInfo) =>
me && (me.moderates.length > 0 || isAdmin(me))
export const isAdmin = (me: MyUserInfo) => me.local_user_view.person.admin
@@ -100,7 +100,7 @@
<FormattedNumber number={post.counts.comments} />
</Button>
<div class="ml-auto" />
{#if $user && isMod($user, post.community.id)}
{#if $user && isMod($user, post.community)}
<ModerationMenu item={post} community={post.community} />
{/if}
<Menu alignment="bottom-right" class="overflow-auto" let:toggleOpen>