Merge branch 'dev' of git.silversoft.se:Imbus/FrostByte into dev

This commit is contained in:
Imbus 2024-03-23 00:40:09 +01:00
commit 2fe0090422
2 changed files with 19 additions and 4 deletions

View file

@ -1,13 +1,28 @@
import { JSXElement } from "solid-js";
import { JSXElement, createSignal, onMount } from "solid-js";
import { CommentsIcon } from "../../Util/Icons";
import { getCommentCount } from "../../Util/api";
export default function CommentsButton(props: { postId: string }): JSXElement {
const [commentCount, setCommentCount] = createSignal(0);
const handleComments = async (): Promise<void> => {
try {
const count = await getCommentCount(props.postId);
setCommentCount(count);
} catch (error) {
console.error("Error reading comments:", error);
}
};
// Fetch comment count when the component mounts
onMount(handleComments);
export default function CommentsButton(): JSXElement {
return (
<div class="flex p-1">
<CommentsIcon />
<span class="text-1xl countdown px-1.5 pt-1.5 text-center">
<p style={{ "--value": 12 }} />
<p style={{ "--value": commentCount() }} />
</span>
</div>
);

View file

@ -36,7 +36,7 @@ export function PostSegment(props: { post: Post }): JSXElement {
<div class="card-actions justify-between">
<div class="flex">
<EngagementButton postId={post.id} />
<CommentsButton />
<CommentsButton postId={post.id} />
</div>
<ToPostButton post={post} />
</div>