feat: only show comment form when you press 'create comment'
This commit is contained in:
1 parent
1b4bd8081f
commit
856ce6bbec
3 files changed
+27
-14
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "1.10.0",
|
"version": "1.10.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ export function insertCommentIntoTree(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildCommentsTreeAsync(
|
export async function buildCommentsTreeAsync(comments: CommentView[]) {
|
||||||
comments: CommentView[],
|
|
||||||
) {
|
|
||||||
const result = buildCommentsTree(comments)
|
const result = buildCommentsTree(comments)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
ChevronDoubleUp,
|
ChevronDoubleUp,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
|
Plus,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.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,
|
max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let showCreateComment = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -281,16 +284,28 @@
|
|||||||
</div>
|
</div>
|
||||||
{:then comments}
|
{:then comments}
|
||||||
{#if $profile?.user}
|
{#if $profile?.user}
|
||||||
<CommentForm
|
{#if showCreateComment}
|
||||||
postId={post.post_view.post.id}
|
<CommentForm
|
||||||
on:comment={(comment) =>
|
postId={post.post_view.post.id}
|
||||||
(comments.comments = [
|
on:comment={(comment) =>
|
||||||
comment.detail.comment_view,
|
(comments.comments = [
|
||||||
...comments.comments,
|
comment.detail.comment_view,
|
||||||
])}
|
...comments.comments,
|
||||||
locked={post.post_view.post.locked ||
|
])}
|
||||||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
|
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}
|
{/if}
|
||||||
{#await buildCommentsTreeAsync(comments.comments)}
|
{#await buildCommentsTreeAsync(comments.comments)}
|
||||||
<div class="h-16 mx-auto grid place-items-center">
|
<div class="h-16 mx-auto grid place-items-center">
|
||||||
|
|||||||
Reference in new issue
Block a user