fix: hide create community for instances where that is disabled
This commit is contained in:
7 files changed
+70
-29
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/lemmy.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
@@ -10,18 +11,20 @@
|
||||
{$t('nav.create.label')}
|
||||
</Header>
|
||||
|
||||
<Tabs
|
||||
style="subpage"
|
||||
routes={[
|
||||
{
|
||||
href: '/create/post',
|
||||
name: $t('nav.create.post'),
|
||||
},
|
||||
{
|
||||
href: '/create/community',
|
||||
name: $t('nav.create.community'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{#if !site || !site.data?.site_view.local_site.community_creation_admin_only}
|
||||
<Tabs
|
||||
style="subpage"
|
||||
routes={[
|
||||
{
|
||||
href: '/create/post',
|
||||
name: $t('nav.create.post'),
|
||||
},
|
||||
{
|
||||
href: '/create/community',
|
||||
name: $t('nav.create.community'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{@render children?.()}
|
||||
@@ -1,19 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import PostForm from '$lib/components/lemmy/post/form/PostForm.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { onDestroy } from 'svelte'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
onMount(() => {
|
||||
if (!profile.current?.jwt) {
|
||||
goto('/login')
|
||||
}
|
||||
})
|
||||
|
||||
let community = getSessionStorage('lastSeenCommunity') as
|
||||
| { id: number; name: string }
|
||||
| undefined
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
isUser,
|
||||
} from '$lib/lemmy/item.js'
|
||||
import { searchParam } from '$lib/util.svelte.js'
|
||||
import { Button, Select, Spinner } from 'mono-svelte'
|
||||
import { Button, Select, Spinner, TextLoader } from 'mono-svelte'
|
||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||
import {
|
||||
AdjustmentsHorizontal,
|
||||
@@ -145,8 +145,7 @@
|
||||
class="flex gap-2 items-center my-4"
|
||||
out:slide={{ axis: 'y', easing: expoOut }}
|
||||
>
|
||||
<Spinner width={24} />
|
||||
<span>{$t('routes.search.federating')}</span>
|
||||
<TextLoader>{$t('routes.search.federating')}</TextLoader>
|
||||
</div>
|
||||
{:then object}
|
||||
{#if object}
|
||||
@@ -169,7 +168,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/await}
|
||||
<CommonList items={data.results.value} animate size="lg">
|
||||
<CommonList items={data.results.value}>
|
||||
{#snippet item(result)}
|
||||
{#if isPostView(result)}
|
||||
<PostItem post={result} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import { client } from '$lib/lemmy.svelte.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
@@ -9,14 +9,17 @@ export async function load({ params, url, fetch }) {
|
||||
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New'
|
||||
|
||||
const user = await getClient(undefined, fetch).getPersonDetails({
|
||||
const user = await client({ func: fetch }).getPersonDetails({
|
||||
limit: 20,
|
||||
page: page,
|
||||
username: params.name,
|
||||
sort: sort,
|
||||
})
|
||||
|
||||
const items = [...user.posts, ...user.comments]
|
||||
const items = [
|
||||
...(type == 'posts' || type == 'all' ? user.posts : []),
|
||||
...(type == 'comments' || type == 'all' ? user.comments : []),
|
||||
]
|
||||
|
||||
if (sort == 'TopAll') {
|
||||
items.sort(
|
||||
|
||||
Reference in new issue
Block a user