postmerge

This commit is contained in:
Untone 2024-05-04 20:21:00 +03:00
parent b4d6171cea
commit 7af4e91792
4 changed files with 26 additions and 18 deletions

View File

@ -30,7 +30,7 @@ export const RatingControl = (props: RatingControlProps) => {
const [isLoading, setIsLoading] = createSignal(false)
const [ratings, setRatings] = createSignal<Reaction[]>([])
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(
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 } })

View File

@ -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,

View File

@ -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) => {
<Show when={isSessionLoaded()} keyed={true}>
<div class={clsx('col-auto col-lg-7', styles.usernav)}>
<div class={styles.userControl}>
<Show when={isCreatePostButtonVisible() && isAuthenticated()}>
<Show when={isCreatePostButtonVisible() && author()?.id}>
<div
class={clsx(
styles.userControlItem,
styles.userControlItemVerbose,
styles.userControlItemCreate,
// styles.userControlItemCreate,
)}
>
<a href={getPagePath(router, 'create')}>
@ -223,12 +223,12 @@ export const HeaderAuth = (props: Props) => {
</div>
</Show>
<Show when={isCreatePostButtonVisible() && !isAuthenticated()}>
<Show when={isCreatePostButtonVisible() && !author()?.id}>
<div
class={clsx(
styles.userControlItem,
styles.userControlItemVerbose,
styles.userControlItemCreate,
// styles.userControlItemCreate,
)}
>
<a href={getPagePath(router, 'create')}>

View File

@ -45,9 +45,11 @@
.info {
@include font-size(1.4rem);
border: none;
//display: flex;
//flex-direction: column;
// display: flex;
// flex-direction: column;
&:hover {
background: unset;
@ -61,11 +63,13 @@
.title {
@include font-size(2.2rem);
font-weight: bold;
}
.description {
@include font-size(1.6rem);
line-height: 1.4;
margin: 0.8rem 0;
-webkit-line-clamp: 2;
@ -103,6 +107,7 @@
.title {
@include font-size(1.4rem);
font-weight: 500;
line-height: 1em;
color: var(--blue-500);
@ -111,7 +116,9 @@
.description {
color: var(--black-400);
@include font-size(1.2rem);
font-weight: 500;
margin: 0;
}