feat: only show comment form when you press 'create comment'

This commit is contained in:
Xyphyn committed 2023-09-23 15:03:41 -07:00
1 parent 1b4bd8081f
commit 856ce6bbec
3 files changed
+27 -14

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "1.10.0",
"version": "1.10.1",
"private": true,
"scripts": {
"dev": "vite dev",
+1 -3
View File
@@ -112,9 +112,7 @@ export function insertCommentIntoTree(
}
}
export async function buildCommentsTreeAsync(
comments: CommentView[],
) {
export async function buildCommentsTreeAsync(comments: CommentView[]) {
const result = buildCommentsTree(comments)
return result
@@ -14,6 +14,7 @@
ChevronDoubleUp,
ExclamationTriangle,
Icon,
Plus,
} from 'svelte-hero-icons'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
@@ -102,6 +103,8 @@
max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3,
})
}
let showCreateComment = false
</script>
<svelte:head>
@@ -281,16 +284,28 @@
</div>
{:then comments}
{#if $profile?.user}
<CommentForm
postId={post.post_view.post.id}
on:comment={(comment) =>
(comments.comments = [
comment.detail.comment_view,
...comments.comments,
])}
locked={post.post_view.post.locked ||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
/>
{#if showCreateComment}
<CommentForm
postId={post.post_view.post.id}
on:comment={(comment) =>
(comments.comments = [
comment.detail.comment_view,
...comments.comments,
])}
locked={post.post_view.post.locked ||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
/>
{:else}
<Button
on:click={() => (showCreateComment = !showCreateComment)}
class="w-max"
size="lg"
rounding="lg"
>
<Icon src={Plus} size="16" mini slot="prefix" />
Add a comment
</Button>
{/if}
{/if}
{#await buildCommentsTreeAsync(comments.comments)}
<div class="h-16 mx-auto grid place-items-center">