{#if node.comment_view.comment.updated}
diff --git a/src/lib/components/lemmy/comment/CommentActions.svelte b/src/lib/components/lemmy/comment/CommentActions.svelte
index af241cf9..b1b6d237 100644
--- a/src/lib/components/lemmy/comment/CommentActions.svelte
+++ b/src/lib/components/lemmy/comment/CommentActions.svelte
@@ -34,7 +34,8 @@
@@ -93,7 +94,7 @@
{comment.saved ? 'Unsave' : 'Save'}
- {#if $profile?.user && $profile.jwt && isCommentMutable(comment, $profile.user.local_user_view)}
+ {#if $profile?.user && $profile.jwt && $profile.user.local_user_view.person.id == comment.creator.id}
{
diff --git a/src/lib/components/lemmy/comment/CommentVote.svelte b/src/lib/components/lemmy/comment/CommentVote.svelte
index ad70ceb5..7d1abb92 100644
--- a/src/lib/components/lemmy/comment/CommentVote.svelte
+++ b/src/lib/components/lemmy/comment/CommentVote.svelte
@@ -12,97 +12,69 @@
import { userSettings } from '$lib/settings'
import { profile } from '$lib/auth.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
- import { Button } from 'mono-svelte'
+ import { Button, buttonColor, toast } from 'mono-svelte'
+ import { vote as voteItem } from '$lib/lemmy/contentview'
+ import { shouldShowVoteColor } from '../post/PostVote.svelte'
+ import { fly } from 'svelte/transition'
export let vote: number = 0
- export let score: number
+ export let upvotes: number
+ export let downvotes: number
export let commentId: number
- async function upvote() {
- if (!$profile?.jwt) return
-
- const upvoted = vote == 1
-
- if (vote == -1) {
- score += 2
- } else if (vote == 1) {
- score -= 1
- } else if (vote == 0) {
- score += 1
+ const castVote = async (newVote: number) => {
+ if (!$profile?.jwt) {
+ toast({ content: 'You must be logged in to vote.', type: 'warning' })
+ return
}
- vote = Number(!upvoted)
-
- await getClient()
- .likeComment({
- score: upvoted ? 0 : 1,
- comment_id: commentId,
- })
- .catch((_) => undefined)
+ vote = newVote
+ const res = await getClient().likeComment({
+ comment_id: commentId,
+ score: vote,
+ })
+ ;({ upvotes, downvotes } = res.comment_view.counts)
}
-
- async function downvote() {
- if (!$profile?.jwt) return
-
- const upvoted = vote == -1
-
- if (vote == -1) {
- score += 1
- } else if (vote == 1) {
- score -= 2
- } else if (vote == 0) {
- score -= 1
- }
-
- vote = -Number(!upvoted)
-
- await getClient()
- .likeComment({
- score: upvoted ? 0 : -1,
- comment_id: commentId,
- })
- .catch((_) => undefined)
- }
-
- const voteColor = (vote: number) => `
- ${vote == 1 ? '!text-blue-500' : vote == -1 ? '!text-red-500' : ''}
- `
-
-
+
+
castVote(vote == -1 ? 0 : -1)}
+ class="flex items-center gap-0.5 {buttonColor.tertiary} transition-colors border-0 !pr-2
+ {vote == -1 ? shouldShowVoteColor(vote, 'downvotes') : ''}"
>
-
-
-
-
-
+
+
+ {#key downvotes}
+
+
+
+ {/key}
+
+
diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte
index 799fcd14..99a2612e 100644
--- a/src/lib/components/lemmy/post/PostVote.svelte
+++ b/src/lib/components/lemmy/post/PostVote.svelte
@@ -1,3 +1,17 @@
+
+
-