postmerge-fix
This commit is contained in:
parent
cc951c305b
commit
4e2152b8b0
|
@ -57,7 +57,7 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
)
|
)
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
reactionEntities,
|
() => reactionEntities,
|
||||||
(reactions) => {
|
(reactions) => {
|
||||||
const ratings = Object.values(reactions).filter((r) => !r?.reply_to)
|
const ratings = Object.values(reactions).filter((r) => !r?.reply_to)
|
||||||
const likes = ratings.filter((rating) => rating.kind === 'LIKE').length
|
const likes = ratings.filter((rating) => rating.kind === 'LIKE').length
|
||||||
|
|
|
@ -160,7 +160,7 @@ export const LoginForm = () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Show when={submitError()}>
|
<Show when={submitError()}>
|
||||||
<div class={clsx('form-message--error', styles.submitError)}>{submitError()}</div>
|
<div class={clsx('form-message--error', styles.validationError)}>{submitError()}</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Accessor, JSX } from 'solid-js'
|
import type { JSX } from 'solid-js'
|
||||||
|
|
||||||
import { createContext, createSignal, onCleanup, useContext } from 'solid-js'
|
import { createContext, onCleanup, useContext } from 'solid-js'
|
||||||
import { createStore, reconcile } from 'solid-js/store'
|
import { createStore, reconcile } from 'solid-js/store'
|
||||||
|
|
||||||
import { apiClient } from '../graphql/client/core'
|
import { apiClient } from '../graphql/client/core'
|
||||||
|
@ -9,12 +9,12 @@ import { useLocalize } from './localize'
|
||||||
import { useSnackbar } from './snackbar'
|
import { useSnackbar } from './snackbar'
|
||||||
|
|
||||||
type ReactionsContextType = {
|
type ReactionsContextType = {
|
||||||
reactionEntities: Accessor<Record<number, Reaction>>
|
reactionEntities: Record<number, Reaction>
|
||||||
loadReactionsBy: ({
|
loadReactionsBy: ({
|
||||||
by,
|
by,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
}: {
|
}: {
|
||||||
by: ReactionBy
|
by: ReactionBy
|
||||||
limit?: number
|
limit?: number
|
||||||
offset?: number
|
offset?: number
|
||||||
|
@ -36,21 +36,21 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
const { showSnackbar } = useSnackbar()
|
const { showSnackbar } = useSnackbar()
|
||||||
|
|
||||||
const loadReactionsBy = async ({
|
const loadReactionsBy = async ({
|
||||||
by,
|
by,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
}: {
|
}: {
|
||||||
by: ReactionBy
|
by: ReactionBy
|
||||||
limit?: number
|
limit?: number
|
||||||
offset?: number
|
offset?: number
|
||||||
}): Promise<Reaction[]> => {
|
}): Promise<Reaction[]> => {
|
||||||
const reactions = await apiClient.getReactionsBy({ by, limit, offset })
|
const reactions = await apiClient.getReactionsBy({ by, limit, offset })
|
||||||
const newReactionEntities = reactions.reduce(
|
const newReactionEntities = reactions.reduce(
|
||||||
(acc: { [reaction_id: number]: Reaction }, reaction: Reaction) => {
|
(acc: { [reaction_id: number]: Reaction }, reaction: Reaction) => {
|
||||||
acc[reaction.id] = reaction
|
acc[reaction.id] = reaction
|
||||||
return acc
|
return acc
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
setReactionEntities(newReactionEntities)
|
setReactionEntities(newReactionEntities)
|
||||||
return reactions
|
return reactions
|
||||||
|
@ -66,14 +66,14 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
|
|
||||||
if ([ReactionKind.Like, ReactionKind.Dislike].includes(reaction.kind)) {
|
if ([ReactionKind.Like, ReactionKind.Dislike].includes(reaction.kind)) {
|
||||||
const oppositeReactionKind =
|
const oppositeReactionKind =
|
||||||
reaction.kind === ReactionKind.Like ? ReactionKind.Dislike : ReactionKind.Like
|
reaction.kind === ReactionKind.Like ? ReactionKind.Dislike : ReactionKind.Like
|
||||||
|
|
||||||
const oppositeReaction = Object.values(reactionEntities).find(
|
const oppositeReaction = Object.values(reactionEntities).find(
|
||||||
(r) =>
|
(r) =>
|
||||||
r.kind === oppositeReactionKind &&
|
r.kind === oppositeReactionKind &&
|
||||||
r.created_by.slug === reaction.created_by.slug &&
|
r.created_by.slug === reaction.created_by.slug &&
|
||||||
r.shout.id === reaction.shout.id &&
|
r.shout.id === reaction.shout.id &&
|
||||||
r.reply_to === reaction.reply_to,
|
r.reply_to === reaction.reply_to,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (oppositeReaction) {
|
if (oppositeReaction) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user