[146] handle voting error
This commit is contained in:
parent
06e68fca4a
commit
c421467f04
|
@ -231,5 +231,6 @@
|
|||
"Your name will appear on your profile page and as your signature in publications, comments and responses.": "Your name will appear on your profile page and as your signature in publications, comments and responses",
|
||||
"zine": "zine",
|
||||
"By time": "By time",
|
||||
"New only": "New only"
|
||||
"New only": "New only",
|
||||
"You can't vote twice": "You cannot vote twice"
|
||||
}
|
||||
|
|
|
@ -248,6 +248,5 @@
|
|||
"user already exist": "пользователь уже существует",
|
||||
"view": "просмотр",
|
||||
"zine": "журнал",
|
||||
"By time": "По порядку",
|
||||
"New only": "Только новые"
|
||||
"By time": "По порядку"
|
||||
}
|
||||
|
|
|
@ -7,14 +7,19 @@ import { useReactions } from '../../context/reactions'
|
|||
import { createMemo, For } from 'solid-js'
|
||||
import { loadShout } from '../../stores/zine/articles'
|
||||
import { Popup } from '../_shared/Popup'
|
||||
import { useLocalize } from '../../context/localize'
|
||||
import { useSnackbar } from '../../context/snackbar'
|
||||
|
||||
type Props = {
|
||||
comment: Reaction
|
||||
}
|
||||
|
||||
export const CommentRatingControl = (props: Props) => {
|
||||
const { t } = useLocalize()
|
||||
const { userSlug } = useSession()
|
||||
|
||||
const {
|
||||
actions: { showSnackbar }
|
||||
} = useSnackbar()
|
||||
const {
|
||||
reactionEntities,
|
||||
actions: { createReaction, deleteReaction, loadReactionsBy }
|
||||
|
@ -52,6 +57,7 @@ export const CommentRatingControl = (props: Props) => {
|
|||
}
|
||||
|
||||
const handleRatingChange = async (isUpvote: boolean) => {
|
||||
try {
|
||||
if (isUpvoted()) {
|
||||
await deleteCommentReaction(ReactionKind.Like)
|
||||
} else if (isDownvoted()) {
|
||||
|
@ -63,6 +69,9 @@ export const CommentRatingControl = (props: Props) => {
|
|||
replyTo: props.comment.id
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
showSnackbar({ type: 'error', body: t('Error') })
|
||||
}
|
||||
|
||||
await loadShout(props.comment.shout.slug)
|
||||
await loadReactionsBy({
|
||||
|
@ -72,7 +81,6 @@ export const CommentRatingControl = (props: Props) => {
|
|||
|
||||
return (
|
||||
<div class={styles.commentRating}>
|
||||
{!canVote()}
|
||||
<button
|
||||
role="button"
|
||||
disabled={!canVote() || !userSlug()}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { clsx } from 'clsx'
|
|||
import styles from './Settings.module.scss'
|
||||
import { useProfileForm } from '../../context/profile'
|
||||
import validateUrl from '../../utils/validateUrl'
|
||||
|
||||
import { createFileUploader, UploadFile } from '@solid-primitives/upload'
|
||||
import { Loading } from '../../components/_shared/Loading'
|
||||
import { useSession } from '../../context/session'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// debug nested objects console.log('message', clone(obj))
|
||||
|
||||
export const clone = <T>(obj: T) => JSON.parse(JSON.stringify(obj))
|
||||
export const clone = <T>(obj: T): T => JSON.parse(JSON.stringify(obj))
|
||||
|
|
Loading…
Reference in New Issue
Block a user