This commit is contained in:
parent
af38f4a3a0
commit
fbc2b15ba1
|
@ -1,11 +1,11 @@
|
||||||
import type { Author } from '../../graphql/schema/core.gen'
|
import type { Author } from '../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
|
import { Show, createSignal } from 'solid-js'
|
||||||
|
|
||||||
|
import { apiClient } from '../../graphql/client/core'
|
||||||
|
|
||||||
import styles from './AuthorRatingControl.module.scss'
|
import styles from './AuthorRatingControl.module.scss'
|
||||||
import { Show, createSignal } from 'solid-js'
|
|
||||||
import { useLocalize } from '../../context/localize'
|
|
||||||
import { apiClient } from '../../graphql/client/core'
|
|
||||||
|
|
||||||
interface AuthorRatingControlProps {
|
interface AuthorRatingControlProps {
|
||||||
author: Author
|
author: Author
|
||||||
|
@ -15,12 +15,13 @@ interface AuthorRatingControlProps {
|
||||||
export const AuthorRatingControl = (props: AuthorRatingControlProps) => {
|
export const AuthorRatingControl = (props: AuthorRatingControlProps) => {
|
||||||
const isUpvoted = false
|
const isUpvoted = false
|
||||||
const isDownvoted = false
|
const isDownvoted = false
|
||||||
const { t } = useLocalize()
|
|
||||||
// eslint-disable-next-line unicorn/consistent-function-scoping
|
// eslint-disable-next-line unicorn/consistent-function-scoping
|
||||||
const handleRatingChange = async (isUpvote: boolean) => {
|
const handleRatingChange = async (isUpvote: boolean) => {
|
||||||
console.log('handleRatingChange', { isUpvote })
|
console.log('handleRatingChange', { isUpvote })
|
||||||
if (props.author?.slug) {
|
if (props.author?.slug) {
|
||||||
await apiClient.rateAuthor({ rated_slug: props.author?.slug, value: isUpvote ? 1 : -1 })
|
const value = isUpvote ? 1 : -1
|
||||||
|
await apiClient.rateAuthor({ rated_slug: props.author?.slug, value })
|
||||||
|
setRating((r) => r + value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import { useInbox } from '../../context/inbox'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
import { useSession } from '../../context/session'
|
import { useSession } from '../../context/session'
|
||||||
import { useRouter } from '../../stores/router'
|
import { useRouter } from '../../stores/router'
|
||||||
import { AuthorsSortBy, useAuthorsStore } from '../../stores/zine/authors'
|
|
||||||
import { showModal } from '../../stores/ui'
|
import { showModal } from '../../stores/ui'
|
||||||
|
import { AuthorsSortBy, useAuthorsStore } from '../../stores/zine/authors'
|
||||||
import { Icon } from '../_shared/Icon'
|
import { Icon } from '../_shared/Icon'
|
||||||
import { Popover } from '../_shared/Popover'
|
import { Popover } from '../_shared/Popover'
|
||||||
import SimplifiedEditor from '../Editor/SimplifiedEditor'
|
import SimplifiedEditor from '../Editor/SimplifiedEditor'
|
||||||
|
@ -59,10 +59,7 @@ export const InboxView = (props: Props) => {
|
||||||
const { author } = useSession()
|
const { author } = useSession()
|
||||||
const currentUserId = createMemo(() => author()?.id)
|
const currentUserId = createMemo(() => author()?.id)
|
||||||
const { changeSearchParams, searchParams } = useRouter<InboxSearchParams>()
|
const { changeSearchParams, searchParams } = useRouter<InboxSearchParams>()
|
||||||
const { sortedAuthors } = useAuthorsStore({
|
|
||||||
authors: props.authors,
|
|
||||||
sortBy: (searchParams()?.by as AuthorsSortBy) || 'name',
|
|
||||||
})
|
|
||||||
const messagesContainerRef: { current: HTMLDivElement } = {
|
const messagesContainerRef: { current: HTMLDivElement } = {
|
||||||
current: null,
|
current: null,
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { createGraphQLClient } from '../createGraphQLClient'
|
||||||
import createArticle from '../mutation/core/article-create'
|
import createArticle from '../mutation/core/article-create'
|
||||||
import deleteShout from '../mutation/core/article-delete'
|
import deleteShout from '../mutation/core/article-delete'
|
||||||
import updateArticle from '../mutation/core/article-update'
|
import updateArticle from '../mutation/core/article-update'
|
||||||
|
import rateAuthor from '../mutation/core/author-rate'
|
||||||
import followMutation from '../mutation/core/follow'
|
import followMutation from '../mutation/core/follow'
|
||||||
import reactionCreate from '../mutation/core/reaction-create'
|
import reactionCreate from '../mutation/core/reaction-create'
|
||||||
import reactionDestroy from '../mutation/core/reaction-destroy'
|
import reactionDestroy from '../mutation/core/reaction-destroy'
|
||||||
|
@ -44,7 +45,6 @@ import topicBySlug from '../query/core/topic-by-slug'
|
||||||
import topicsAll from '../query/core/topics-all'
|
import topicsAll from '../query/core/topics-all'
|
||||||
import userFollowedTopics from '../query/core/topics-by-author'
|
import userFollowedTopics from '../query/core/topics-by-author'
|
||||||
import topicsRandomQuery from '../query/core/topics-random'
|
import topicsRandomQuery from '../query/core/topics-random'
|
||||||
import rateAuthor from '../mutation/core/author-rate'
|
|
||||||
|
|
||||||
const publicGraphQLClient = createGraphQLClient('core')
|
const publicGraphQLClient = createGraphQLClient('core')
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
import type { PageProps } from './types'
|
||||||
|
|
||||||
|
import { createSignal, onMount } from 'solid-js'
|
||||||
|
|
||||||
import { PageLayout } from '../components/_shared/PageLayout'
|
import { PageLayout } from '../components/_shared/PageLayout'
|
||||||
import { ShowOnlyOnClient } from '../components/_shared/ShowOnlyOnClient'
|
import { ShowOnlyOnClient } from '../components/_shared/ShowOnlyOnClient'
|
||||||
import { InboxView } from '../components/Views/Inbox'
|
import { InboxView } from '../components/Views/Inbox'
|
||||||
import { InboxProvider } from '../context/inbox'
|
import { InboxProvider } from '../context/inbox'
|
||||||
import { useLocalize } from '../context/localize'
|
import { useLocalize } from '../context/localize'
|
||||||
import type { PageProps } from './types'
|
|
||||||
import { createSignal, onMount } from 'solid-js'
|
|
||||||
import { loadAllAuthors } from '../stores/zine/authors'
|
import { loadAllAuthors } from '../stores/zine/authors'
|
||||||
|
|
||||||
export const InboxPage = (props: PageProps) => {
|
export const InboxPage = (props: PageProps) => {
|
||||||
|
|
|
@ -61,7 +61,7 @@ export const loadAuthor = async ({
|
||||||
author_id,
|
author_id,
|
||||||
}: {
|
}: {
|
||||||
slug: string
|
slug: string
|
||||||
author_id: number
|
author_id?: number
|
||||||
}): Promise<Author> => {
|
}): Promise<Author> => {
|
||||||
const author = await apiClient.getAuthor({ slug, author_id })
|
const author = await apiClient.getAuthor({ slug, author_id })
|
||||||
addAuthors([author])
|
addAuthors([author])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user