Refactor community question comments display
- Adjusted spacing for the comments section for better visual alignment. - Wrapped comments rendering in a conditional to ensure proper display only when comments exist. - Maintained functionality for upvoting and deleting comments while improving code readability.
This commit is contained in:
@@ -223,35 +223,37 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="my-8">
|
<div class="my-2">
|
||||||
{pluralize($t('community.answers'), communityApi.question?.comments.length ?? 0, true)}
|
{pluralize($t('community.answers'), communityApi.question?.comments.length ?? 0, true)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
{#if !!communityApi.question?.comments?.length}
|
||||||
{#each communityApi.question?.comments as commentItem (commentItem.id)}
|
<div class="space-y-2">
|
||||||
<CommunityCommentItem
|
{#each communityApi.question?.comments as commentItem (commentItem.id)}
|
||||||
comment={commentItem}
|
<CommunityCommentItem
|
||||||
isVoted={!!voted.comment[commentItem.id]}
|
comment={commentItem}
|
||||||
{isValidAnswer}
|
isVoted={!!voted.comment[commentItem.id]}
|
||||||
isAuthorOrAdmin={commentItem.author?.id === $profile.id || $isOrgAdmin === true}
|
{isValidAnswer}
|
||||||
upVote={() => {
|
isAuthorOrAdmin={commentItem.author?.id === $profile.id || $isOrgAdmin === true}
|
||||||
if (voted.comment[commentItem.id]) return;
|
upVote={() => {
|
||||||
|
if (voted.comment[commentItem.id]) return;
|
||||||
|
|
||||||
voted.comment[commentItem.id] = true;
|
voted.comment[commentItem.id] = true;
|
||||||
|
|
||||||
communityApi.upvotePost({
|
communityApi.upvotePost({
|
||||||
id: commentItem.id,
|
id: commentItem.id,
|
||||||
isQuestion: false
|
isQuestion: false
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onDelete={() => {
|
onDelete={() => {
|
||||||
console.log('deleting commentItem', commentItem);
|
console.log('deleting commentItem', commentItem);
|
||||||
communityApi.deleteCommentState.shouldDelete = true;
|
communityApi.deleteCommentState.shouldDelete = true;
|
||||||
communityApi.deleteCommentState.commentId = commentItem.id;
|
communityApi.deleteCommentState.commentId = commentItem.id;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user