From f19de68568354296de99cf63cd2ec4ebaac1d15f Mon Sep 17 00:00:00 2001 From: ilia tapazukk Date: Sat, 22 Apr 2023 14:36:38 +0000 Subject: [PATCH] Show author subscriptions --- public/locales/en/translation.json | 4 +- public/locales/ru/translation.json | 4 +- src/components/Views/Author.tsx | 92 +++++++++++++++++--- src/graphql/query/author-following-topics.ts | 19 ++++ src/graphql/query/author-following-users.ts | 12 +++ src/graphql/query/author-following.ts | 23 ----- src/graphql/types.gen.ts | 15 +++- src/utils/apiClient.ts | 13 ++- 8 files changed, 139 insertions(+), 43 deletions(-) create mode 100644 src/graphql/query/author-following-topics.ts create mode 100644 src/graphql/query/author-following-users.ts delete mode 100644 src/graphql/query/author-following.ts diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index d690a0a0..849c8cf0 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -235,5 +235,7 @@ "Bookmarks": "Bookmarks", "Logout": "Logout", "This comment has not yet been rated": "This comment has not yet been rated", - "This post has not been rated yet": "This post has not been rated yet" + "This post has not been rated yet": "This post has not been rated yet", + "Author subscriptions": "Подписки на авторов", + "Topic subscriptions": "Подписки на темы" } diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index cb056a2b..252fc47e 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -253,5 +253,7 @@ "Bookmarks": "Закладки", "Logout": "Выход", "This comment has not yet been rated": "Этот комментарий еще пока никто не оценил", - "This post has not been rated yet": "Эту публикацию еще пока никто не оценил" + "This post has not been rated yet": "Эту публикацию еще пока никто не оценил", + "Author subscriptions": "Подписки на авторов", + "Topic subscriptions": "Подписки на темы" } diff --git a/src/components/Views/Author.tsx b/src/components/Views/Author.tsx index a8354f3a..655eeea2 100644 --- a/src/components/Views/Author.tsx +++ b/src/components/Views/Author.tsx @@ -1,5 +1,5 @@ import { Show, createMemo, createSignal, Switch, onMount, For, Match, createEffect } from 'solid-js' -import type { Author, Shout } from '../../graphql/types.gen' +import type { Author, Shout, Topic } from '../../graphql/types.gen' import { Row1 } from '../Feed/Row1' import { Row2 } from '../Feed/Row2' import { AuthorFull } from '../Author/Full' @@ -19,6 +19,7 @@ import { apiClient } from '../../utils/apiClient' import { Comment } from '../Article/Comment' import { useLocalize } from '../../context/localize' import { AuthorRatingControl } from '../Author/AuthorRatingControl' +import { TopicCard } from '../Topic/Card' type AuthorProps = { shouts: Shout[] @@ -27,7 +28,17 @@ type AuthorProps = { } export type AuthorPageSearchParams = { - by: '' | 'viewed' | 'rating' | 'commented' | 'recent' | 'followed' | 'about' | 'popular' + by: + | '' + | 'viewed' + | 'rating' + | 'commented' + | 'recent' + | 'subscribed-authors' + | 'subscribed-topics' + | 'followers' + | 'about' + | 'popular' } export const PRERENDERED_ARTICLES_COUNT = 12 @@ -41,6 +52,34 @@ export const AuthorView = (props: AuthorProps) => { const author = authorEntities()[props.authorSlug] const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const [followers, setFollowers] = createSignal([]) + const [followingUsers, setFollowingUsers] = createSignal([]) + const [subscribedTopics, setSubscribedTopics] = createSignal([]) + + onMount(async () => { + if (!props.author.slug) return + try { + const userSubscribers = await apiClient.getAuthorFollowers({ slug: props.author.slug }) + setFollowers(userSubscribers) + } catch (error) { + console.log('[getAuthorFollowers]', error) + } + + try { + const authorSubscriptionsUsers = await apiClient.getAuthorFollowingUsers({ slug: props.author.slug }) + setFollowingUsers(authorSubscriptionsUsers) + } catch (error) { + console.log('[getAuthorFollowingUsers]', error) + } + + try { + const authorSubscriptionsTopics = await apiClient.getAuthorFollowingTopics({ + slug: props.author.slug + }) + setSubscribedTopics(authorSubscriptionsTopics) + } catch (error) { + console.log('[getAuthorFollowing]', error) + } + }) onMount(() => { if (!searchParams().by) { @@ -114,23 +153,26 @@ export const AuthorView = (props: AuthorProps) => { {t('Publications')} -
  • -
  • +
  • + +
  • +
  • + +
  • - {/* -
  • - -
  • - */}