improve: update commentvote
This commit is contained in:
1 parent
ee9dbf1071
commit
d3168c1d1d
6 files changed
+82
-120
No files matched your search
@@ -1,3 +1,17 @@
|
||||
<script lang="ts" context="module">
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
export const voteColor = (vote: number, border: boolean = false) =>
|
||||
vote == 1 ? `!text-blue-500` : vote == -1 ? `!text-red-500` : ''
|
||||
|
||||
export const shouldShowVoteColor = (
|
||||
vote: number,
|
||||
type: 'upvotes' | 'downvotes'
|
||||
): string =>
|
||||
(vote == -1 && type == 'downvotes') || (vote == 1 && type == 'upvotes')
|
||||
? voteColor(vote)
|
||||
: ''
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import type { Post } from 'lemmy-js-client'
|
||||
@@ -14,7 +28,6 @@
|
||||
import { Button, Popover, buttonColor, toast } from 'mono-svelte'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
|
||||
export let post: Post
|
||||
export let vote: number = 0
|
||||
@@ -24,19 +37,6 @@
|
||||
|
||||
let oldScore = score
|
||||
|
||||
const voteColor = (vote: number, border: boolean = false) =>
|
||||
vote == 1 ? `!text-blue-500` : vote == -1 ? `!text-red-500` : ''
|
||||
|
||||
const shouldShowVoteColor = (
|
||||
vote: number,
|
||||
type: 'upvotes' | 'downvotes'
|
||||
): string =>
|
||||
(vote == -1 && type == 'downvotes') ||
|
||||
(vote == 1 && type == 'upvotes') ||
|
||||
!$userSettings.separateVotes
|
||||
? voteColor(vote)
|
||||
: ''
|
||||
|
||||
const castVote = async (newVote: number) => {
|
||||
if (!$profile?.jwt) {
|
||||
toast({ content: 'You must be logged in to vote.', type: 'warning' })
|
||||
|
||||
Reference in new issue
Block a user