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 { notifications, profile } from '$lib/app/auth.svelte'
|
||||
import { t } from '$lib/app/i18n'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
|
||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
||||
import { Menu, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
Bars3,
|
||||
@@ -71,7 +70,7 @@
|
||||
</NavButton>
|
||||
<div class="hidden md:block md:flex-1"></div>
|
||||
<div class="sr-only md:not-sr-only md:contents">
|
||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
||||
{#if profile.isAdmin}
|
||||
<NavButton
|
||||
href="/admin"
|
||||
label={$t('nav.admin')}
|
||||
@@ -80,7 +79,7 @@
|
||||
isSelectedFilter={(path) => path.startsWith('/admin')}
|
||||
/>
|
||||
{/if}
|
||||
{#if amModOfAny(profile.current?.user)}
|
||||
{#if profile.isMod()}
|
||||
<NavButton
|
||||
href="/moderation"
|
||||
label={$t('nav.moderation')}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import { settings } from '$lib/app/settings.svelte'
|
||||
import { theme } from '$lib/app/theme/theme.svelte'
|
||||
import InstanceCard from '$lib/feature/instance/InstanceCard.svelte'
|
||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
@@ -70,7 +69,7 @@
|
||||
</Badge>
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if amModOfAny(profile.current.user)}
|
||||
{#if profile.isMod()}
|
||||
<MenuButton href="/moderation" icon={ShieldCheck}>
|
||||
{$t('routes.moderation.feed')}
|
||||
{#snippet suffix()}
|
||||
@@ -78,7 +77,7 @@
|
||||
{/snippet}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if profile.current.user && isAdmin(profile.current.user)}
|
||||
{#if profile.isAdmin}
|
||||
<MenuButton href="/admin/applications" icon={ServerStack}>
|
||||
{$t('routes.admin.applications.title')}
|
||||
{#snippet suffix()}
|
||||
|
||||
@@ -9,7 +9,6 @@ import { settings } from '$lib/app/settings.svelte'
|
||||
import { theme, type ThemeData } from '$lib/app/theme/theme.svelte'
|
||||
import { fullCommunityName } from '$lib/app/util.svelte'
|
||||
import type { ResumableItem } from '$lib/feature/legacy/item'
|
||||
import { amModOfAny, isAdmin } from '$lib/feature/moderation/moderation'
|
||||
import {
|
||||
ArrowRightOnRectangle,
|
||||
ArrowTrendingDown,
|
||||
@@ -92,7 +91,7 @@ export function getGroups(
|
||||
name: t.get('nav.communities'),
|
||||
icon: GlobeAlt,
|
||||
},
|
||||
...(amModOfAny(profile.user)
|
||||
...(currentProfile.isMod()
|
||||
? [
|
||||
{
|
||||
href: '/moderation',
|
||||
@@ -101,7 +100,7 @@ export function getGroups(
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(profile.user && isAdmin(profile.user)
|
||||
...(currentProfile.isAdmin
|
||||
? [
|
||||
{
|
||||
href: '/admin',
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
|
||||
let {
|
||||
showLabel = false,
|
||||
hidden = false,
|
||||
children,
|
||||
}: { showLabel?: boolean; children: Snippet } = $props()
|
||||
}: { showLabel?: boolean; hidden?: boolean; children: Snippet } = $props()
|
||||
</script>
|
||||
|
||||
<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>
|
||||
<hr
|
||||
|
||||
Reference in new issue
Block a user