From e332a8a674092ba5090ba3b639a6802bc485fadf Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Tue, 6 Dec 2022 17:03:55 +0100 Subject: [PATCH] article page. & comments fix --- src/components/Article/CommentsTree.tsx | 11 +++---- src/components/Article/FullArticle.tsx | 2 +- src/components/Author/Card.tsx | 3 +- src/components/Nav/HeaderAuth.tsx | 4 +-- src/components/Topic/Card.tsx | 3 +- src/components/Views/Feed.tsx | 2 +- src/context/session.tsx | 43 ++++++++++++++----------- src/graphql/types.gen.ts | 4 +-- src/stores/zine/reactions.ts | 6 +--- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index a15facad..44938ae2 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -1,11 +1,10 @@ -import { For, Show } from 'solid-js' +import { For, Show, createMemo, createSignal, onMount } from 'solid-js' import { useSession } from '../../context/session' import Comment from './Comment' import { t } from '../../utils/intl' import { showModal } from '../../stores/ui' import styles from '../../styles/Article.module.scss' import { useReactionsStore } from '../../stores/zine/reactions' -import { createMemo, createSignal, onMount } from 'solid-js' import type { Reaction } from '../../graphql/types.gen' import { clsx } from 'clsx' import { byCreated, byStat } from '../../utils/sortby' @@ -14,17 +13,17 @@ import { Loading } from '../Loading' const ARTICLE_COMMENTS_PAGE_SIZE = 50 const MAX_COMMENT_LEVEL = 6 -export const CommentsTree = (props: { shout: string; reactions?: Reaction[] }) => { +export const CommentsTree = (props: { shoutSlug: string }) => { const [getCommentsPage, setCommentsPage] = createSignal(0) const [commentsOrder, setCommentsOrder] = createSignal<'rating' | 'createdAt'>('createdAt') const [isCommentsLoading, setIsCommentsLoading] = createSignal(false) const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const { session } = useSession() - const { sortedReactions, loadReactionsBy } = useReactionsStore({ reactions: props.reactions }) + const { sortedReactions, loadReactionsBy } = useReactionsStore() const reactions = createMemo(() => sortedReactions() .sort(commentsOrder() === 'rating' ? byStat('rating') : byCreated) - .filter((r) => r.shout.slug === props.shout) + .filter((r) => r.shout.slug === props.shoutSlug) ) const loadMore = async () => { @@ -33,7 +32,7 @@ export const CommentsTree = (props: { shout: string; reactions?: Reaction[] }) = setIsCommentsLoading(true) const { hasMore } = await loadReactionsBy({ - by: { shout: props.shout, comment: true }, + by: { shout: props.shoutSlug, comment: true }, limit: ARTICLE_COMMENTS_PAGE_SIZE, offset: page * ARTICLE_COMMENTS_PAGE_SIZE }) diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index f29ebde2..2783e112 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -222,7 +222,7 @@ export const FullArticle = (props: ArticleProps) => { )} - + ) diff --git a/src/components/Author/Card.tsx b/src/components/Author/Card.tsx index bf7b0cec..95fa35d7 100644 --- a/src/components/Author/Card.tsx +++ b/src/components/Author/Card.tsx @@ -32,6 +32,7 @@ interface AuthorCardProps { export const AuthorCard = (props: AuthorCardProps) => { const { session, + isSessionLoaded, actions: { loadSession } } = useSession() @@ -100,7 +101,7 @@ export const AuthorCard = (props: AuthorCardProps) => { - +
{ const [visibleWarnings, setVisibleWarnings] = createSignal(false) const { warnings } = useWarningsStore() - const { session, isAuthenticated } = useSession() + const { session, isSessionLoaded, isAuthenticated } = useSession() const toggleWarnings = () => setVisibleWarnings(!visibleWarnings()) @@ -38,7 +38,7 @@ export const HeaderAuth = (props: HeaderAuthProps) => { return ( - +
diff --git a/src/components/Topic/Card.tsx b/src/components/Topic/Card.tsx index 8dcd2f23..5dcf8c23 100644 --- a/src/components/Topic/Card.tsx +++ b/src/components/Topic/Card.tsx @@ -28,6 +28,7 @@ interface TopicProps { export const TopicCard = (props: TopicProps) => { const { session, + isSessionLoaded, actions: { loadSession } } = useSession() @@ -89,7 +90,7 @@ export const TopicCard = (props: TopicProps) => { classList={{ 'col-md-3': !props.compact && !props.subscribeButtonBottom }} > - +