feat: add community purging
This commit is contained in:
1 parent
93e144a837
commit
b379fff441
3 files changed
+96
-17
No files matched your search
@@ -1,13 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { amMod } from '$lib/components/lemmy/moderation/moderation.js'
|
import {
|
||||||
|
amMod,
|
||||||
|
isAdmin,
|
||||||
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
import { Popover, toast } from 'mono-svelte'
|
import {
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
Modal,
|
||||||
|
Popover,
|
||||||
|
removeToast,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { client, getClient } from '$lib/lemmy.js'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { fullCommunityName } from '$lib/util.js'
|
import { fullCommunityName } from '$lib/util.js'
|
||||||
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
|
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
|
||||||
@@ -16,8 +26,11 @@
|
|||||||
Calendar,
|
Calendar,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
|
EllipsisHorizontal,
|
||||||
|
Fire,
|
||||||
Icon,
|
Icon,
|
||||||
Minus,
|
Minus,
|
||||||
|
NoSymbol,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
Plus,
|
Plus,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
@@ -70,8 +83,64 @@
|
|||||||
community_view.blocked = !blocked
|
community_view.blocked = !blocked
|
||||||
loading.blocking = false
|
loading.blocking = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let purgingCommunity = false
|
||||||
|
let purgeEnabled = false
|
||||||
|
$: if (purgingCommunity) {
|
||||||
|
purgeEnabled = false
|
||||||
|
setTimeout(() => {
|
||||||
|
purgeEnabled = true
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function purgeCommunity() {
|
||||||
|
purgingCommunity = false
|
||||||
|
const purgeToast = toast({ content: 'Purging community...', loading: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await client().purgeCommunity({
|
||||||
|
community_id: community_view.community.id,
|
||||||
|
})
|
||||||
|
removeToast(purgeToast)
|
||||||
|
toast({ content: 'Purged that community.', type: 'success' })
|
||||||
|
} catch (e) {
|
||||||
|
toast({ content: e as any, type: 'error' })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if purgingCommunity}
|
||||||
|
<Modal bind:open={purgingCommunity}>
|
||||||
|
<svelte:fragment slot="title">Purging Community</svelte:fragment>
|
||||||
|
<p>
|
||||||
|
Purging community <span class="font-bold">
|
||||||
|
{community_view.community.title}
|
||||||
|
</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"
|
||||||
|
on:click={() => (purgingCommunity = false)}
|
||||||
|
class="flex-1"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="lg"
|
||||||
|
color="danger"
|
||||||
|
on:click={purgeCommunity}
|
||||||
|
disabled={!purgeEnabled}
|
||||||
|
class="flex-1"
|
||||||
|
>
|
||||||
|
Purge
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<StickyCard>
|
<StickyCard>
|
||||||
<div class="flex flex-row gap-3 items-center">
|
<div class="flex flex-row gap-3 items-center">
|
||||||
<div class="flex-shrink-0">
|
<div class="flex-shrink-0">
|
||||||
@@ -165,17 +234,8 @@
|
|||||||
? 'Unsubscribe'
|
? 'Unsubscribe'
|
||||||
: 'Subscribe'}
|
: 'Subscribe'}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<div class="flex flex-row gap-2 ml-auto">
|
||||||
disabled={loading.blocking}
|
{#if $profile.user && amMod($profile.user, community_view.community)}
|
||||||
loading={loading.blocking}
|
|
||||||
color="danger"
|
|
||||||
size="lg"
|
|
||||||
on:click={block}
|
|
||||||
>
|
|
||||||
{community_view.blocked ? 'Unblock' : 'Block'}
|
|
||||||
</Button>
|
|
||||||
{#if $profile.user && amMod($profile.user, community_view.community)}
|
|
||||||
<div class="flex flex-row gap-2 ml-auto">
|
|
||||||
<Button
|
<Button
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
@@ -185,8 +245,26 @@
|
|||||||
>
|
>
|
||||||
<Icon src={Cog6Tooth} mini size="16" slot="prefix" />
|
<Icon src={Cog6Tooth} mini size="16" slot="prefix" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
<Menu origin="bottom-right">
|
||||||
|
<Button size="square-md" slot="target">
|
||||||
|
<Icon src={EllipsisHorizontal} size="16" mini slot="prefix" />
|
||||||
|
</Button>
|
||||||
|
<MenuButton color="danger-subtle" size="lg" on:click={block}>
|
||||||
|
<Icon src={NoSymbol} size="16" mini slot="prefix" />
|
||||||
|
{community_view.blocked ? 'Unblock' : 'Block'}
|
||||||
|
</MenuButton>
|
||||||
|
{#if $profile.user && isAdmin($profile.user)}
|
||||||
|
<MenuButton
|
||||||
|
color="danger-subtle"
|
||||||
|
on:click={() => (purgingCommunity = !purgingCommunity)}
|
||||||
|
>
|
||||||
|
<Icon src={Fire} size="16" mini slot="prefix" />
|
||||||
|
Purge
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Markdown source={community_view.community.description} />
|
<Markdown source={community_view.community.description} />
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ export function client({
|
|||||||
init?: RequestInit | undefined
|
init?: RequestInit | undefined
|
||||||
) => Promise<Response>
|
) => Promise<Response>
|
||||||
auth?: string
|
auth?: string
|
||||||
}) {
|
} = {}) {
|
||||||
if (!instanceURL) instanceURL = get(instance)
|
if (!instanceURL) instanceURL = get(instance)
|
||||||
|
|
||||||
let jwt = auth ? auth : get(profile)?.jwt
|
let jwt = auth ? auth : get(profile)?.jwt
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const FEATURES = {
|
|||||||
unproxiedImageUpload: '0.19.0',
|
unproxiedImageUpload: '0.19.0',
|
||||||
cursorPagination: '0.19.0',
|
cursorPagination: '0.19.0',
|
||||||
newTotp: '0.19.0',
|
newTotp: '0.19.0',
|
||||||
|
blockInstances: '0.19.0',
|
||||||
}
|
}
|
||||||
|
|
||||||
type Feature = keyof typeof FEATURES
|
type Feature = keyof typeof FEATURES
|
||||||
|
|||||||
Reference in new issue
Block a user