Merge branch 'dev' of git.silversoft.se:Imbus/FrostByte into dev
This commit is contained in:
commit
2fe0090422
2 changed files with 19 additions and 4 deletions
|
@ -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>
|
||||
);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue