From 7623f719a568d5f3faa46393e23bd7c9097df52c Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 12 Jul 2024 14:19:58 +0300 Subject: [PATCH] biomed --- src/app.tsx | 2 +- .../Views/AllAuthors/AllAuthors.tsx | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 9f431cce..df984dfd 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,6 +4,7 @@ import { FileRoutes } from '@solidjs/start/router' import { type JSX, Suspense } from 'solid-js' import { Loading } from './components/_shared/Loading' +import { AuthorsProvider } from './context/authors' import { EditorProvider } from './context/editor' import { FeedProvider } from './context/feed' import { GraphQLClientProvider } from './context/graphql' @@ -11,7 +12,6 @@ import { LocalizeProvider } from './context/localize' import { SessionProvider } from './context/session' import { TopicsProvider } from './context/topics' import { UIProvider } from './context/ui' // snackbar included -import { AuthorsProvider } from './context/authors' import '~/styles/app.scss' export const Providers = (props: { children?: JSX.Element }) => { diff --git a/src/components/Views/AllAuthors/AllAuthors.tsx b/src/components/Views/AllAuthors/AllAuthors.tsx index 8f068977..77c5ccdc 100644 --- a/src/components/Views/AllAuthors/AllAuthors.tsx +++ b/src/components/Views/AllAuthors/AllAuthors.tsx @@ -1,6 +1,6 @@ import { useSearchParams } from '@solidjs/router' import { clsx } from 'clsx' -import { For, Show, createEffect, createMemo, createSignal, on, onMount } from 'solid-js' +import { For, Show, createEffect, createMemo, createSignal } from 'solid-js' import { AuthorBadge } from '~/components/Author/AuthorBadge' import { InlineLoader } from '~/components/InlineLoader' import { Button } from '~/components/_shared/Button' @@ -34,7 +34,7 @@ export const AllAuthors = (props: Props) => { const [searchParams, changeSearchParams] = useSearchParams<{ by?: string }>() const { authorsSorted, setAuthorsSort, loadAuthors } = useAuthors() const [loading, setLoading] = createSignal(false) - const [currentAuthors, setCurrentAuthors] = createSignal([]) + const [_currentAuthors, setCurrentAuthors] = createSignal([]) // UPDATE Fetch authors initially and when searchParams.by changes createEffect(() => { @@ -51,8 +51,8 @@ export const AllAuthors = (props: Props) => { sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.shouts || 0) - (a.stat?.shouts || 0)) console.log('Sorted by Shouts:', sortedAuthors.slice(0, 5)) } else if (searchParams.by === 'followers') { - sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.followers || 0) - (a.stat?.followers || 0)); - console.log('Sorted by Followers:', sortedAuthors.slice(0, 5)); + sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.followers || 0) - (a.stat?.followers || 0)) + console.log('Sorted by Followers:', sortedAuthors.slice(0, 5)) } console.log('After Sorting:', sortedAuthors.slice(0, 5)) return sortedAuthors @@ -68,8 +68,8 @@ export const AllAuthors = (props: Props) => { // filter const [searchQuery, setSearchQuery] = createSignal('') const [filteredAuthors, setFilteredAuthors] = createSignal([]) - createEffect(() => - authors() && setFilteredAuthors(dummyFilter(authors(), searchQuery(), lang()) as Author[]) + createEffect( + () => authors() && setFilteredAuthors(dummyFilter(authors(), searchQuery(), lang()) as Author[]) ) // store by first char @@ -116,10 +116,10 @@ export const AllAuthors = (props: Props) => { }) const loadMoreAuthors = () => { - const by = searchParams?.by as 'followers' | 'shouts' | undefined; - if (!by) return; - const nextPage = currentPage()[by] + 1; - fetchAuthors(by, nextPage).then(() => setCurrentPage({ ...currentPage(), [by]: nextPage })); + const by = searchParams?.by as 'followers' | 'shouts' | undefined + if (!by) return + const nextPage = currentPage()[by] + 1 + fetchAuthors(by, nextPage).then(() => setCurrentPage({ ...currentPage(), [by]: nextPage })) } const TabNavigator = () => ( @@ -133,21 +133,27 @@ export const AllAuthors = (props: Props) => { ['view-switcher__item--selected']: !searchParams?.by || searchParams?.by === 'shouts' })} > - changeSearchParams({ by: 'shouts' })}>{t('By shouts')} + changeSearchParams({ by: 'shouts' })}> + {t('By shouts')} +
  • - changeSearchParams({ by: 'followers' })}>{t('By popularity')} + changeSearchParams({ by: 'followers' })}> + {t('By popularity')} +
  • - changeSearchParams({ by: 'name' })}>{t('By name')} + changeSearchParams({ by: 'name' })}> + {t('By name')} +