diff --git a/src/lib/app/auth.svelte.ts b/src/lib/app/auth.svelte.ts index dd7271bc..28e96a6d 100644 --- a/src/lib/app/auth.svelte.ts +++ b/src/lib/app/auth.svelte.ts @@ -12,7 +12,7 @@ import { DEFAULT_INSTANCE_URL } from './instance.svelte' import { instanceToURL, moveItem } from './util.svelte' function getFromStorage(key: string): T | undefined { - if (typeof localStorage == 'undefined') return undefined + if (!browser) return const lc = localStorage.getItem(key) if (!lc) return undefined @@ -20,7 +20,7 @@ function getFromStorage(key: string): T | undefined { } function setFromStorage(key: string, item: any, stringify: boolean = true) { - if (typeof localStorage == 'undefined') return + if (!browser) return return localStorage.setItem(key, stringify ? JSON.stringify(item) : item) } diff --git a/src/lib/app/i18n/en.json b/src/lib/app/i18n/en.json index 8e683111..9f6d2a8c 100644 --- a/src/lib/app/i18n/en.json +++ b/src/lib/app/i18n/en.json @@ -301,8 +301,6 @@ "commentCount": "Comments", "addComment": "Add a comment", "scrollToTop": "Scroll to top", - "remoteView": "Remote View", - "localView": "Local View", "thread": { "single": "You're viewing a single thread.", "allComments": "All comments", diff --git a/src/lib/ui/layout/EndPlaceholder.svelte b/src/lib/ui/layout/EndPlaceholder.svelte index f5da08ed..bf1deaaf 100644 --- a/src/lib/ui/layout/EndPlaceholder.svelte +++ b/src/lib/ui/layout/EndPlaceholder.svelte @@ -23,11 +23,17 @@ none: '', } + const alignments = { + default: '', + center: '', + } + interface Props { class?: ClassValue size?: keyof typeof sizes color?: keyof typeof colors margin?: keyof typeof margins + alignment?: keyof typeof alignments border?: boolean children?: import('svelte').Snippet action?: import('svelte').Snippet @@ -43,9 +49,19 @@ color = 'subtle', margin = 'none', element = 'h3', + alignment = 'default', }: Props = $props() +{#snippet divider()} +
+{/snippet} +
- - {@render children?.()} - -
+ {#if alignment == 'center'} + {@render divider()} + {/if} + {#if children} + + {@render children?.()} + + {/if} + {#if alignment == 'default'} + {@render divider()} + {/if} {@render action?.()} + {#if alignment == 'center'} + {@render divider()} + {/if}
diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte index 3bc3f8fe..e6b458cf 100644 --- a/src/routes/post/[instance]/[id=integer]/+page.svelte +++ b/src/routes/post/[instance]/[id=integer]/+page.svelte @@ -11,12 +11,10 @@ parseTags, PostActions, PostItem, - postLink, PostMedia, PostMeta, type Tag, } from '$lib/feature/post' - import Fixate from '$lib/ui/generic/Fixate.svelte' import Placeholder from '$lib/ui/info/Placeholder.svelte' import { CommonList } from '$lib/ui/layout' import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte' @@ -24,12 +22,7 @@ import FormattedNumber from '$lib/ui/util/FormattedNumber.svelte' import { Button, Expandable, toast } from 'mono-svelte' import { onMount } from 'svelte' - import { - ArrowRight, - ChatBubbleLeftRight, - ChevronDoubleUp, - Icon, - } from 'svelte-hero-icons/dist' + import { ChatBubbleLeftRight, ChevronDoubleUp } from 'svelte-hero-icons/dist' import { expoOut } from 'svelte/easing' import { fly } from 'svelte/transition' import CommentProvider from './CommentProvider.svelte' @@ -59,10 +52,7 @@ } }) - let loading = $state(false) - async function reloadComments() { - loading = true data.data.value.comments = client() .getComments({ page: 1, @@ -73,7 +63,6 @@ max_depth: data.data.value.post.counts.comments > 100 ? 1 : 3, }) .then((i) => i.comments) - loading = false data.data.value.params.thread.singleThread = false } @@ -214,34 +203,6 @@ {/if} {/await} -{#await data.data.value.comments then comments} - {#if data.data.value.params.thread.showContext || data.data.value.params.thread.singleThread} - - - - {/if} -{/await}
@@ -288,6 +249,8 @@ onupdate={reloadComments} bind:sort={data.data.value.params.comments.sort} virtualize={!page.url.searchParams.get('noVirtualize')} + showContext={data.data.value.params.thread.showContext} + singleThread={data.data.value.params.thread.singleThread} /> {#if comments.length == 0} void focus?: string virtualize?: boolean + showContext?: boolean + singleThread?: boolean } let { @@ -39,6 +43,8 @@ onupdate, focus, virtualize = true, + showContext, + singleThread, }: Props = $props() let commenting = $state(false) @@ -65,12 +71,7 @@ color="primary" rounding="xl" disabled={(post.post.locked || post.banned_from_community) && - !( - profile.current?.user?.local_user_view.local_user.admin || - profile.current?.user?.moderates - .map((c) => c.community.id) - .includes(post.community.id) - )} + !(profile.isAdmin || profile.isMod(post.community))} onclick={() => (commenting = true)} > @@ -155,6 +156,41 @@ > {/if} + +{#snippet allCommentsPlaceholder()} + + {#snippet action()} + + {/snippet} + +{/snippet} + +{#if singleThread && !showContext} + {@render allCommentsPlaceholder()} +{/if} + +{#if showContext && tree[0]} + +
+{/if} {#if virtualize} {:else} @@ -164,3 +200,7 @@ {/if} + +{#if singleThread && !showContext} + {@render allCommentsPlaceholder()} +{/if}