From e00086ee701a437aa201832096667991bba93c1e Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 10 Dec 2023 01:15:02 +0300 Subject: [PATCH] resolvers-updates --- src/components/Article/Comment/Comment.tsx | 2 +- src/components/Topic/Card.tsx | 2 +- src/components/Topic/TopicBadge/TopicBadge.tsx | 2 +- src/components/Views/AllTopics.tsx | 2 +- src/components/Views/Feed.tsx | 2 +- src/graphql/client/core.ts | 8 ++++---- src/graphql/query/core/authors-all.ts | 4 ++-- src/pages/allAuthors.page.server.ts | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index 44b7b46a..bb2c2cad 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -52,7 +52,7 @@ export const Comment = (props: Props) => { actions: { showSnackbar }, } = useSnackbar() - const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author().slug) + const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author()?.slug) const comment = createMemo(() => props.comment) const body = createMemo(() => (comment().body || '').trim()) diff --git a/src/components/Topic/Card.tsx b/src/components/Topic/Card.tsx index 07b96c6e..264a079f 100644 --- a/src/components/Topic/Card.tsx +++ b/src/components/Topic/Card.tsx @@ -84,7 +84,7 @@ export const TopicCard = (props: TopicProps) => { } const title = createMemo(() => - capitalize(lang() == 'en' ? props.topic.slug.replace(/-/, ' ') : props.topic.title || ''), + capitalize(lang() == 'en' ? props.topic.slug.replace(/-/g, ' ') : props.topic.title || ''), ) return ( diff --git a/src/components/Topic/TopicBadge/TopicBadge.tsx b/src/components/Topic/TopicBadge/TopicBadge.tsx index 17b11cea..b9dfa55a 100644 --- a/src/components/Topic/TopicBadge/TopicBadge.tsx +++ b/src/components/Topic/TopicBadge/TopicBadge.tsx @@ -54,7 +54,7 @@ export const TopicBadge = (props: Props) => { /> - {lang() == 'en' ? capitalize(props.topic.slug.replace(/-/, ' ')) : props.topic.title} + {lang() == 'en' ? capitalize(props.topic.slug.replace(/-/g, ' ')) : props.topic.title} { {(topic) => (
- {lang() == 'en' ? capitalize(topic.slug.replace(/-/, ' ')) : topic.title} + {lang() == 'en' ? capitalize(topic.slug.replace(/-/g, ' ')) : topic.title} {topic.stat.shouts}
diff --git a/src/components/Views/Feed.tsx b/src/components/Views/Feed.tsx index c0a6273e..6c915b3e 100644 --- a/src/components/Views/Feed.tsx +++ b/src/components/Views/Feed.tsx @@ -228,7 +228,7 @@ export const FeedView = (props: Props) => { {(topic) => ( - {lang() == 'en' ? topic.slug.replace(/-/, ' ') : topic.title} + {lang() == 'en' ? topic.slug.replace(/-/g, ' ') : topic.title} {' '} )} diff --git a/src/graphql/client/core.ts b/src/graphql/client/core.ts index 64c28d6f..c82160ae 100644 --- a/src/graphql/client/core.ts +++ b/src/graphql/client/core.ts @@ -72,12 +72,12 @@ export const apiClient = { } return response.data.get_topics_all }, - getAllAuthors: async () => { - const response = await publicGraphQLClient.query(authorsAll, {}).toPromise() + getAllAuthors: async (limit: number = 50, offset: number = 0) => { + const response = await publicGraphQLClient.query(authorsAll, { limit, offset }).toPromise() if (response.error) { - console.debug('[graphql.client.core] get_authors_all', response.error) + console.debug('[graphql.client.core] load_authors_all', response.error) } - return response.data.get_authors_all + return response.data.load_authors_all }, getAuthor: async (params: { slug?: string; author_id?: number; user?: string }): Promise => { const response = await publicGraphQLClient.query(authorBy, params).toPromise() diff --git a/src/graphql/query/core/authors-all.ts b/src/graphql/query/core/authors-all.ts index 1caec910..3d3f97a6 100644 --- a/src/graphql/query/core/authors-all.ts +++ b/src/graphql/query/core/authors-all.ts @@ -1,8 +1,8 @@ import { gql } from '@urql/core' export default gql` - query AuthorsAllQuery { - get_authors_all { + query AuthorsAllQuery($limit: Int, $offset: Int) { + load_authors_all(limit: $limit, offset: $offset) { id slug name diff --git a/src/pages/allAuthors.page.server.ts b/src/pages/allAuthors.page.server.ts index a8e31794..de7e51ff 100644 --- a/src/pages/allAuthors.page.server.ts +++ b/src/pages/allAuthors.page.server.ts @@ -4,7 +4,7 @@ import type { PageContext } from '../renderer/types' import { apiClient } from '../graphql/client/core' export const onBeforeRender = async (_pageContext: PageContext) => { - const allAuthors = await apiClient.getAllAuthors() + const allAuthors = await apiClient.getAllAuthors() // limit 50, offset 0 const pageProps: PageProps = { allAuthors, seo: { title: '' } }