diff --git a/src/components/Article/RatingControl.tsx b/src/components/Article/RatingControl.tsx index 435c15b8..ba9aeaa5 100644 --- a/src/components/Article/RatingControl.tsx +++ b/src/components/Article/RatingControl.tsx @@ -30,7 +30,7 @@ export const RatingControl = (props: RatingControlProps) => { const [isLoading, setIsLoading] = createSignal(false) const [ratings, setRatings] = createSignal([]) const [myRate, setMyRate] = createSignal() - const [total, setTotal] = createSignal(props.comment?.stat?.rating || props.shout?.stat?.rating || 0) + const [_total, setTotal] = createSignal(props.comment?.stat?.rating || props.shout?.stat?.rating || 0) createEffect( on( @@ -87,14 +87,7 @@ export const RatingControl = (props: RatingControlProps) => { requireAuthentication(async () => { setIsLoading(true) - if (!myRate()) { - console.debug('[RatingControl.handleRatingChange] wasnt voted by you before', myRate()) - const rateInput = { kind: voteKind, shout: props.shout?.id } - const fakeId = Date.now() + Math.floor(Math.random() * 1000) - // const savedRatings = [...props.ratings] - mergeProps(props.ratings, [...props.ratings, { ...rateInput, id: fakeId, created_by: author() }]) - const _ = await createReaction(rateInput) - } else { + if (myRate()) { console.debug('[RatingControl.handleRatingChange] already has your vote', myRate()) const oppositeKind = voteKind === ReactionKind.Like ? ReactionKind.Dislike : ReactionKind.Like if (myRate()?.kind === oppositeKind) { @@ -109,6 +102,13 @@ export const RatingControl = (props: RatingControlProps) => { if (myRate()?.kind === voteKind) { console.debug(`[RatingControl.handleRatingChange] cant vote ${voteKind} twice`) } + } else { + console.debug('[RatingControl.handleRatingChange] wasnt voted by you before', myRate()) + const rateInput = { kind: voteKind, shout: props.shout?.id } + const fakeId = Date.now() + Math.floor(Math.random() * 1000) + // const savedRatings = [...props.ratings] + mergeProps(props.ratings, [...props.ratings, { ...rateInput, id: fakeId, created_by: author() }]) + const _ = await createReaction(rateInput) } const ratings = await loadReactionsBy({ by: { shout: props.shout?.slug, rating: true } }) diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index ee9718bc..d2968b53 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -1,6 +1,6 @@ import { openPage } from '@nanostores/router' import { clsx } from 'clsx' -import { Match, Show, Switch, createEffect, createMemo, createSignal } from 'solid-js' +import { Match, Show, Switch, createEffect, createMemo, createSignal, on } from 'solid-js' import { useFollowing } from '../../../context/following' import { useLocalize } from '../../../context/localize' @@ -28,6 +28,7 @@ type Props = { onInvite?: (id: number) => void selected?: boolean subscriptionsMode?: boolean + isFollowed?: boolean } export const AuthorBadge = (props: Props) => { const { mediaMatches } = useMediaQuery() @@ -71,7 +72,7 @@ export const AuthorBadge = (props: Props) => { return props.author.name }) - + const [_isFollowed, setIsFollowed] = createSignal() createEffect( on( () => props.isFollowed, diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index 07181abf..9474b07a 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -57,7 +57,7 @@ export const HeaderAuth = (props: Props) => { toggleEditorPanel() } - const handleSaveClick = () => { + const _handleSaveClick = () => { const hasTopics = form.selectedTopics?.length > 0 if (hasTopics) { saveShout(form) @@ -109,12 +109,12 @@ export const HeaderAuth = (props: Props) => {