From 30ff30d099560d90bd05817e93455446c8a0f376 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 3 Sep 2024 13:29:01 +0300 Subject: [PATCH] fmt --- src/components/Views/Author/Author.tsx | 84 ++++++++++++++++---------- src/context/reactions.tsx | 2 +- src/routes/author/[slug]/[...tab].tsx | 4 +- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index bccbcf97..c52ccbe4 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -110,7 +110,7 @@ export const AuthorView = (props: AuthorViewProps) => { }) const handleDeleteComment = (id: number) => { - setCommented((prev) => (prev||[]).filter((comment) => comment.id !== id)) + setCommented((prev) => (prev || []).filter((comment) => comment.id !== id)) } const TabNavigator = () => ( @@ -154,11 +154,17 @@ export const AuthorView = (props: AuthorViewProps) => { } // fx to update author's feed - createEffect(on(feedByAuthor, (byAuthor) => { - const feed = byAuthor[props.authorSlug] as Shout[] - if (!feed) return - setSortedFeed(feed) - },{})) + createEffect( + on( + feedByAuthor, + (byAuthor) => { + const feed = byAuthor[props.authorSlug] as Shout[] + if (!feed) return + setSortedFeed(feed) + }, + {} + ) + ) const [loadMoreCommentsHidden, setLoadMoreCommentsHidden] = createSignal(false) const { commentsByAuthor, addReactions } = useReactions() @@ -176,14 +182,27 @@ export const AuthorView = (props: AuthorViewProps) => { }) const result = await authorCommentsFetcher() result && addReactions(result) - result && setCommented((prev) => [...new Set([...(prev||[]), ...result])]) + result && setCommented((prev) => [...new Set([...(prev || []), ...result])]) restoreScrollPosition() return result as LoadMoreItems } createEffect(() => setCurrentTab(params.tab)) - createEffect(on([author, commented], ([a, ccc]) => a && setLoadMoreCommentsHidden(ccc?.length === a.stat?.comments), {})) - createEffect(on([author, feedByAuthor], ([a, feed]) => a && feed[props.authorSlug] && setLoadMoreHidden(feed[props.authorSlug]?.length === a.stat?.shouts), {})) + createEffect( + on( + [author, commented], + ([a, ccc]) => a && setLoadMoreCommentsHidden(ccc?.length === a.stat?.comments), + {} + ) + ) + createEffect( + on( + [author, feedByAuthor], + ([a, feed]) => + a && feed[props.authorSlug] && setLoadMoreHidden(feed[props.authorSlug]?.length === a.stat?.shouts), + {} + ) + ) return (
@@ -245,26 +264,29 @@ export const AuthorView = (props: AuthorViewProps) => {
- -