biomed
This commit is contained in:
parent
65798a7f60
commit
7623f719a5
|
@ -4,6 +4,7 @@ import { FileRoutes } from '@solidjs/start/router'
|
||||||
import { type JSX, Suspense } from 'solid-js'
|
import { type JSX, Suspense } from 'solid-js'
|
||||||
|
|
||||||
import { Loading } from './components/_shared/Loading'
|
import { Loading } from './components/_shared/Loading'
|
||||||
|
import { AuthorsProvider } from './context/authors'
|
||||||
import { EditorProvider } from './context/editor'
|
import { EditorProvider } from './context/editor'
|
||||||
import { FeedProvider } from './context/feed'
|
import { FeedProvider } from './context/feed'
|
||||||
import { GraphQLClientProvider } from './context/graphql'
|
import { GraphQLClientProvider } from './context/graphql'
|
||||||
|
@ -11,7 +12,6 @@ import { LocalizeProvider } from './context/localize'
|
||||||
import { SessionProvider } from './context/session'
|
import { SessionProvider } from './context/session'
|
||||||
import { TopicsProvider } from './context/topics'
|
import { TopicsProvider } from './context/topics'
|
||||||
import { UIProvider } from './context/ui' // snackbar included
|
import { UIProvider } from './context/ui' // snackbar included
|
||||||
import { AuthorsProvider } from './context/authors'
|
|
||||||
import '~/styles/app.scss'
|
import '~/styles/app.scss'
|
||||||
|
|
||||||
export const Providers = (props: { children?: JSX.Element }) => {
|
export const Providers = (props: { children?: JSX.Element }) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useSearchParams } from '@solidjs/router'
|
import { useSearchParams } from '@solidjs/router'
|
||||||
import { clsx } from 'clsx'
|
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 { AuthorBadge } from '~/components/Author/AuthorBadge'
|
||||||
import { InlineLoader } from '~/components/InlineLoader'
|
import { InlineLoader } from '~/components/InlineLoader'
|
||||||
import { Button } from '~/components/_shared/Button'
|
import { Button } from '~/components/_shared/Button'
|
||||||
|
@ -34,7 +34,7 @@ export const AllAuthors = (props: Props) => {
|
||||||
const [searchParams, changeSearchParams] = useSearchParams<{ by?: string }>()
|
const [searchParams, changeSearchParams] = useSearchParams<{ by?: string }>()
|
||||||
const { authorsSorted, setAuthorsSort, loadAuthors } = useAuthors()
|
const { authorsSorted, setAuthorsSort, loadAuthors } = useAuthors()
|
||||||
const [loading, setLoading] = createSignal<boolean>(false)
|
const [loading, setLoading] = createSignal<boolean>(false)
|
||||||
const [currentAuthors, setCurrentAuthors] = createSignal<Author[]>([])
|
const [_currentAuthors, setCurrentAuthors] = createSignal<Author[]>([])
|
||||||
|
|
||||||
// UPDATE Fetch authors initially and when searchParams.by changes
|
// UPDATE Fetch authors initially and when searchParams.by changes
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
@ -51,8 +51,8 @@ export const AllAuthors = (props: Props) => {
|
||||||
sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.shouts || 0) - (a.stat?.shouts || 0))
|
sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.shouts || 0) - (a.stat?.shouts || 0))
|
||||||
console.log('Sorted by Shouts:', sortedAuthors.slice(0, 5))
|
console.log('Sorted by Shouts:', sortedAuthors.slice(0, 5))
|
||||||
} else if (searchParams.by === 'followers') {
|
} else if (searchParams.by === 'followers') {
|
||||||
sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.followers || 0) - (a.stat?.followers || 0));
|
sortedAuthors = sortedAuthors.sort((a, b) => (b.stat?.followers || 0) - (a.stat?.followers || 0))
|
||||||
console.log('Sorted by Followers:', sortedAuthors.slice(0, 5));
|
console.log('Sorted by Followers:', sortedAuthors.slice(0, 5))
|
||||||
}
|
}
|
||||||
console.log('After Sorting:', sortedAuthors.slice(0, 5))
|
console.log('After Sorting:', sortedAuthors.slice(0, 5))
|
||||||
return sortedAuthors
|
return sortedAuthors
|
||||||
|
@ -68,8 +68,8 @@ export const AllAuthors = (props: Props) => {
|
||||||
// filter
|
// filter
|
||||||
const [searchQuery, setSearchQuery] = createSignal('')
|
const [searchQuery, setSearchQuery] = createSignal('')
|
||||||
const [filteredAuthors, setFilteredAuthors] = createSignal<Author[]>([])
|
const [filteredAuthors, setFilteredAuthors] = createSignal<Author[]>([])
|
||||||
createEffect(() =>
|
createEffect(
|
||||||
authors() && setFilteredAuthors(dummyFilter(authors(), searchQuery(), lang()) as Author[])
|
() => authors() && setFilteredAuthors(dummyFilter(authors(), searchQuery(), lang()) as Author[])
|
||||||
)
|
)
|
||||||
|
|
||||||
// store by first char
|
// store by first char
|
||||||
|
@ -116,10 +116,10 @@ export const AllAuthors = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const loadMoreAuthors = () => {
|
const loadMoreAuthors = () => {
|
||||||
const by = searchParams?.by as 'followers' | 'shouts' | undefined;
|
const by = searchParams?.by as 'followers' | 'shouts' | undefined
|
||||||
if (!by) return;
|
if (!by) return
|
||||||
const nextPage = currentPage()[by] + 1;
|
const nextPage = currentPage()[by] + 1
|
||||||
fetchAuthors(by, nextPage).then(() => setCurrentPage({ ...currentPage(), [by]: nextPage }));
|
fetchAuthors(by, nextPage).then(() => setCurrentPage({ ...currentPage(), [by]: nextPage }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabNavigator = () => (
|
const TabNavigator = () => (
|
||||||
|
@ -133,21 +133,27 @@ export const AllAuthors = (props: Props) => {
|
||||||
['view-switcher__item--selected']: !searchParams?.by || searchParams?.by === 'shouts'
|
['view-switcher__item--selected']: !searchParams?.by || searchParams?.by === 'shouts'
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<a href="#" onClick={() => changeSearchParams({ by: 'shouts' })}>{t('By shouts')}</a>
|
<a href="#" onClick={() => changeSearchParams({ by: 'shouts' })}>
|
||||||
|
{t('By shouts')}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class={clsx({
|
class={clsx({
|
||||||
['view-switcher__item--selected']: searchParams?.by === 'followers'
|
['view-switcher__item--selected']: searchParams?.by === 'followers'
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<a href="#" onClick={() => changeSearchParams({ by: 'followers' })}>{t('By popularity')}</a>
|
<a href="#" onClick={() => changeSearchParams({ by: 'followers' })}>
|
||||||
|
{t('By popularity')}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class={clsx({
|
class={clsx({
|
||||||
['view-switcher__item--selected']: searchParams?.by === 'name'
|
['view-switcher__item--selected']: searchParams?.by === 'name'
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<a href="#" onClick={() => changeSearchParams({ by: 'name' })}>{t('By name')}</a>
|
<a href="#" onClick={() => changeSearchParams({ by: 'name' })}>
|
||||||
|
{t('By name')}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<Show when={searchParams?.by === 'name'}>
|
<Show when={searchParams?.by === 'name'}>
|
||||||
<li class="view-switcher__search">
|
<li class="view-switcher__search">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user