diff --git a/src/lib/components/lemmy/Sort.svelte b/src/lib/components/lemmy/Sort.svelte index 37a517ed..a4b9a5cd 100644 --- a/src/lib/components/lemmy/Sort.svelte +++ b/src/lib/components/lemmy/Sort.svelte @@ -56,7 +56,7 @@ {#if feature('scaledSort', $site?.version)} - + {/if} diff --git a/src/lib/components/lemmy/community/CommunityCard.svelte b/src/lib/components/lemmy/community/CommunityCard.svelte index 677c2fcc..15c939c5 100644 --- a/src/lib/components/lemmy/community/CommunityCard.svelte +++ b/src/lib/components/lemmy/community/CommunityCard.svelte @@ -23,6 +23,7 @@ import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client' import { Button } from 'mono-svelte' import { + BuildingOffice2, Calendar, ChatBubbleOvalLeftEllipsis, Check, @@ -73,10 +74,24 @@ const blocked = community_view.blocked try { + const loading = toast({ + content: `${blocked ? 'Unblocking' : 'blocking'} community...`, + loading: true, + }) + await getClient().blockCommunity({ community_id: community_view.community.id, block: !blocked, }) + + removeToast(loading) + + toast({ + content: `Successfully ${ + blocked ? 'unblocked' : 'blocked' + } that community.`, + type: 'success', + }) } catch (error) { toast({ content: error as any, type: 'error' }) } @@ -108,6 +123,30 @@ toast({ content: e as any, type: 'error' }) } } + + async function blockInstance() { + if (!$profile?.jwt) return + try { + const loading = toast({ + content: `Blocking instance...`, + loading: true, + }) + + await getClient().blockInstance({ + instance_id: community_view.community.instance_id, + block: true, + }) + + removeToast(loading) + + toast({ + content: `Successfully blocked that instance.`, + type: 'success', + }) + } catch (error) { + toast({ content: error as any, type: 'error' }) + } + } {#if purgingCommunity} @@ -276,6 +315,12 @@ {community_view.blocked ? 'Unblock' : 'Block'} + {#if $profile?.user} + + + Block instance + + {/if} {#if $profile?.user && isAdmin($profile.user)} + import Avatar from './Avatar.svelte' + + export let name: string + export let label: string | undefined = undefined + export let icon: string | undefined = undefined + + +
+ +
+ {name} + {label} +
+
diff --git a/src/lib/components/ui/Placeholder.svelte b/src/lib/components/ui/Placeholder.svelte index f11671bb..3a979beb 100644 --- a/src/lib/components/ui/Placeholder.svelte +++ b/src/lib/components/ui/Placeholder.svelte @@ -5,10 +5,13 @@ export let title: string export let description: string | undefined = undefined + export let center: boolean = true
{#if icon}
{/if} -
+

{title}

{#if description} -

{description}

+

+ {description} +

{/if}
diff --git a/src/lib/components/ui/SectionTitle.svelte b/src/lib/components/ui/SectionTitle.svelte index d890cd16..353f4f46 100644 --- a/src/lib/components/ui/SectionTitle.svelte +++ b/src/lib/components/ui/SectionTitle.svelte @@ -1,6 +1,3 @@ - + diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte index f9151e9d..1bd461be 100644 --- a/src/routes/c/[name]/+page.svelte +++ b/src/routes/c/[name]/+page.svelte @@ -11,7 +11,14 @@ import { Button, Modal, toast } from 'mono-svelte' import { afterNavigate } from '$app/navigation' import { browser } from '$app/environment' - import { ChartBar, EllipsisHorizontal, Icon } from 'svelte-hero-icons' + import { + ArrowRight, + ChartBar, + EllipsisHorizontal, + Icon, + XMark, + } from 'svelte-hero-icons' + import Placeholder from '$lib/components/ui/Placeholder.svelte' export let data @@ -89,7 +96,20 @@
- + {#if data.community.community_view.blocked} + + + + {:else} + + {/if} + +
diff --git a/src/routes/profile/(local_user)/blocks/+page.svelte b/src/routes/profile/(local_user)/blocks/+page.svelte index ba77399e..77a4489b 100644 --- a/src/routes/profile/(local_user)/blocks/+page.svelte +++ b/src/routes/profile/(local_user)/blocks/+page.svelte @@ -1,17 +1,22 @@ -{#if data.community_blocks?.length > 0 || data.person_blocks?.length > 0} +{#if data.community_blocks?.length > 0 || data.person_blocks?.length > 0 || (data.my_user?.instance_blocks?.length ?? 0) > 0} + {#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0} +
+ Instances + unblockInstances(i.detail)}> + {#each data.my_user?.instance_blocks as block (block.instance.id)} +
+ + +
+ {/each} +
+
+ {:else} + + {/if} + {#if data.community_blocks?.length > 0} +
+ Communities + unblockCommunity(i.detail)}> + {#each data.community_blocks as block (block.community.id)} +
+ + +
+ {/each} +
+
+ {:else} + + {/if} {#if data.person_blocks?.length > 0}
Users unblockUser(i.detail)}> {#each data.person_blocks as block (block.target.id)}
-
{/each} @@ -78,43 +169,16 @@ - {/if} - - {#if data.community_blocks?.length > 0} -
- Communities - unblockCommunity(i.detail)}> - {#each data.community_blocks as block (block.community.id)} -
- - -
- {/each} -
-
- {:else} - {/if} {:else}
{/if}