postmerge
This commit is contained in:
parent
b4d6171cea
commit
7af4e91792
|
@ -30,7 +30,7 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
const [isLoading, setIsLoading] = createSignal(false)
|
const [isLoading, setIsLoading] = createSignal(false)
|
||||||
const [ratings, setRatings] = createSignal<Reaction[]>([])
|
const [ratings, setRatings] = createSignal<Reaction[]>([])
|
||||||
const [myRate, setMyRate] = createSignal<Reaction | undefined>()
|
const [myRate, setMyRate] = createSignal<Reaction | undefined>()
|
||||||
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(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
|
@ -87,14 +87,7 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
requireAuthentication(async () => {
|
requireAuthentication(async () => {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
|
|
||||||
if (!myRate()) {
|
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 {
|
|
||||||
console.debug('[RatingControl.handleRatingChange] already has your vote', myRate())
|
console.debug('[RatingControl.handleRatingChange] already has your vote', myRate())
|
||||||
const oppositeKind = voteKind === ReactionKind.Like ? ReactionKind.Dislike : ReactionKind.Like
|
const oppositeKind = voteKind === ReactionKind.Like ? ReactionKind.Dislike : ReactionKind.Like
|
||||||
if (myRate()?.kind === oppositeKind) {
|
if (myRate()?.kind === oppositeKind) {
|
||||||
|
@ -109,6 +102,13 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
if (myRate()?.kind === voteKind) {
|
if (myRate()?.kind === voteKind) {
|
||||||
console.debug(`[RatingControl.handleRatingChange] cant vote ${voteKind} twice`)
|
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 } })
|
const ratings = await loadReactionsBy({ by: { shout: props.shout?.slug, rating: true } })
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { openPage } from '@nanostores/router'
|
import { openPage } from '@nanostores/router'
|
||||||
import { clsx } from 'clsx'
|
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 { useFollowing } from '../../../context/following'
|
||||||
import { useLocalize } from '../../../context/localize'
|
import { useLocalize } from '../../../context/localize'
|
||||||
|
@ -28,6 +28,7 @@ type Props = {
|
||||||
onInvite?: (id: number) => void
|
onInvite?: (id: number) => void
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
subscriptionsMode?: boolean
|
subscriptionsMode?: boolean
|
||||||
|
isFollowed?: boolean
|
||||||
}
|
}
|
||||||
export const AuthorBadge = (props: Props) => {
|
export const AuthorBadge = (props: Props) => {
|
||||||
const { mediaMatches } = useMediaQuery()
|
const { mediaMatches } = useMediaQuery()
|
||||||
|
@ -71,7 +72,7 @@ export const AuthorBadge = (props: Props) => {
|
||||||
|
|
||||||
return props.author.name
|
return props.author.name
|
||||||
})
|
})
|
||||||
|
const [_isFollowed, setIsFollowed] = createSignal()
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => props.isFollowed,
|
() => props.isFollowed,
|
||||||
|
|
|
@ -57,7 +57,7 @@ export const HeaderAuth = (props: Props) => {
|
||||||
toggleEditorPanel()
|
toggleEditorPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSaveClick = () => {
|
const _handleSaveClick = () => {
|
||||||
const hasTopics = form.selectedTopics?.length > 0
|
const hasTopics = form.selectedTopics?.length > 0
|
||||||
if (hasTopics) {
|
if (hasTopics) {
|
||||||
saveShout(form)
|
saveShout(form)
|
||||||
|
@ -109,12 +109,12 @@ export const HeaderAuth = (props: Props) => {
|
||||||
<Show when={isSessionLoaded()} keyed={true}>
|
<Show when={isSessionLoaded()} keyed={true}>
|
||||||
<div class={clsx('col-auto col-lg-7', styles.usernav)}>
|
<div class={clsx('col-auto col-lg-7', styles.usernav)}>
|
||||||
<div class={styles.userControl}>
|
<div class={styles.userControl}>
|
||||||
<Show when={isCreatePostButtonVisible() && isAuthenticated()}>
|
<Show when={isCreatePostButtonVisible() && author()?.id}>
|
||||||
<div
|
<div
|
||||||
class={clsx(
|
class={clsx(
|
||||||
styles.userControlItem,
|
styles.userControlItem,
|
||||||
styles.userControlItemVerbose,
|
styles.userControlItemVerbose,
|
||||||
styles.userControlItemCreate,
|
// styles.userControlItemCreate,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<a href={getPagePath(router, 'create')}>
|
<a href={getPagePath(router, 'create')}>
|
||||||
|
@ -223,12 +223,12 @@ export const HeaderAuth = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={isCreatePostButtonVisible() && !isAuthenticated()}>
|
<Show when={isCreatePostButtonVisible() && !author()?.id}>
|
||||||
<div
|
<div
|
||||||
class={clsx(
|
class={clsx(
|
||||||
styles.userControlItem,
|
styles.userControlItem,
|
||||||
styles.userControlItemVerbose,
|
styles.userControlItemVerbose,
|
||||||
styles.userControlItemCreate,
|
// styles.userControlItemCreate,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<a href={getPagePath(router, 'create')}>
|
<a href={getPagePath(router, 'create')}>
|
||||||
|
|
|
@ -45,9 +45,11 @@
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
@include font-size(1.4rem);
|
@include font-size(1.4rem);
|
||||||
|
|
||||||
border: none;
|
border: none;
|
||||||
//display: flex;
|
|
||||||
//flex-direction: column;
|
// display: flex;
|
||||||
|
// flex-direction: column;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: unset;
|
background: unset;
|
||||||
|
@ -61,11 +63,13 @@
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
@include font-size(2.2rem);
|
@include font-size(2.2rem);
|
||||||
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
@include font-size(1.6rem);
|
@include font-size(1.6rem);
|
||||||
|
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
margin: 0.8rem 0;
|
margin: 0.8rem 0;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
|
@ -103,6 +107,7 @@
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
@include font-size(1.4rem);
|
@include font-size(1.4rem);
|
||||||
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
color: var(--blue-500);
|
color: var(--blue-500);
|
||||||
|
@ -111,7 +116,9 @@
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
color: var(--black-400);
|
color: var(--black-400);
|
||||||
|
|
||||||
@include font-size(1.2rem);
|
@include font-size(1.2rem);
|
||||||
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user