From 1af7ba520e3ea74a0a248ad8eb0b0e412dea3e7d Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 18 Jan 2024 15:52:02 +0300 Subject: [PATCH] get-unrated-fix --- src/components/Inbox/DialogCard.tsx | 7 +------ src/components/Views/Feed/Feed.tsx | 11 ++++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/Inbox/DialogCard.tsx b/src/components/Inbox/DialogCard.tsx index e4cb941e..19b5ee03 100644 --- a/src/components/Inbox/DialogCard.tsx +++ b/src/components/Inbox/DialogCard.tsx @@ -30,12 +30,7 @@ const DialogCard = (props: DialogProps) => { () => props.members && props.members.filter((member: ChatMember) => member.id !== props.ownId), ) - const names = createMemo( - () => - companions() - ?.map((companion) => companion.name) - .join(', '), - ) + const names = createMemo(() => (companions() || []).map((companion) => companion.name).join(', ')) return ( diff --git a/src/components/Views/Feed/Feed.tsx b/src/components/Views/Feed/Feed.tsx index 4d3ad854..63d6945f 100644 --- a/src/components/Views/Feed/Feed.tsx +++ b/src/components/Views/Feed/Feed.tsx @@ -136,13 +136,15 @@ export const FeedView = (props: Props) => { return visibility }) + const { session } = useSession() const { actions: { loadReactionsBy }, } = useReactions() - const loadUnratedArticles = async () => { - const result = await apiClient.getUnratedShouts(UNRATED_ARTICLES_COUNT) - setUnratedArticles(result) + if (session()) { + const result = await apiClient.getUnratedShouts(UNRATED_ARTICLES_COUNT) + setUnratedArticles(result) + } } const loadTopComments = async () => { @@ -153,10 +155,9 @@ export const FeedView = (props: Props) => { onMount(() => { loadMore() // eslint-disable-next-line promise/catch-or-return - Promise.all([loadUnratedArticles(), loadTopComments()]).finally(() => setIsRightColumnLoaded(true)) + Promise.all([loadTopComments()]).finally(() => setIsRightColumnLoaded(true)) }) - const { session } = useSession() createEffect(() => { if (session()?.access_token && !unratedArticles()) { loadUnratedArticles()