topics-render-fix

This commit is contained in:
Untone 2024-07-06 01:24:22 +03:00
parent de29d435ec
commit 2d5e9877ee
5 changed files with 12 additions and 14 deletions

View File

@ -220,7 +220,7 @@ export const Header = (props: Props) => {
onMouseOut={hideSubnavigation}
href="/topic"
active={isTopicsVisible()}
body={t('topics')}
body={t('Topics')}
onClick={(event: MouseEvent) => handleToggleMenuByLink(event, 'topic')}
/>
<Link
@ -377,7 +377,7 @@ export const Header = (props: Props) => {
<A href="/dogma">{t('Dogma')}</A>
</li>
<li>
<A href="/principles">{t('Community Principles')}</A>
<A href="/principles">{t('Our principles')}</A>
</li>
<li>
<A href="/guide">{t('Platform Guide')}</A>

View File

@ -34,11 +34,11 @@ export const AllAuthors = (props: Props) => {
const [searchParams] = useSearchParams<{ by?: string }>()
const { authorsSorted, addAuthors, setAuthorsSort } = useAuthors()
createEffect(on(() => searchParams?.by || 'name', setAuthorsSort, {}))
createEffect(() => addAuthors?.([...(props.authors || [])]))
createEffect(on(() => props.authors || [], addAuthors, {}))
const filteredAuthors = createMemo(() => {
const query = searchQuery().toLowerCase()
return authorsSorted?.().filter((a: Author) => a?.name?.toLowerCase().includes(query))
return authorsSorted?.()?.filter((a: Author) => a?.name?.toLowerCase().includes(query)) || []
})
const byLetterFiltered = createMemo<{ [letter: string]: Author[] }>(() => {
@ -165,7 +165,7 @@ export const AllAuthors = (props: Props) => {
</Show>
<Show when={searchParams?.by !== 'name' && props.isLoaded}>
<AuthorsList
allAuthorsLength={authorsSorted?.()?.length || 0}
allAuthorsLength={authorsSorted()?.length || 0}
searchQuery={searchQuery()}
query={searchParams?.by === 'followers' ? 'followers' : 'shouts'}
/>

View File

@ -1,7 +1,7 @@
import { Meta } from '@solidjs/meta'
import { A, useSearchParams } from '@solidjs/router'
import { clsx } from 'clsx'
import { For, Show, createEffect, createMemo, createSignal, on } from 'solid-js'
import { For, Show, createEffect, createMemo, createSignal, on, onMount } from 'solid-js'
import { Loading } from '~/components/_shared/Loading'
import { SearchField } from '~/components/_shared/SearchField'
import { useLocalize } from '~/context/localize'
@ -31,8 +31,9 @@ export const AllTopics = (props: Props) => {
const alphabet = createMemo(() => ABC[lang()])
const { setTopicsSort, sortedTopics } = useTopics()
const topics = createMemo(() => sortedTopics() || props.topics)
const [searchParams] = useSearchParams<{ by?: string }>()
createEffect(on(() => searchParams?.by || 'shouts', setTopicsSort, {}))
const [searchParams, changeSearchParams] = useSearchParams<{ by?: string }>()
createEffect(on(() => searchParams?.by || 'shouts', setTopicsSort, {defer:true}))
onMount(() => setTimeout(() => !searchParams?.by && changeSearchParams({ by: 'shouts'}), 1))
// sorted derivative
const byLetter = createMemo<{ [letter: string]: Topic[] }>(() => {

View File

@ -113,7 +113,7 @@ export const TopicsProvider = (props: { children: JSX.Element }) => {
createEffect(() => {
const topics = Object.values(topicEntities())
console.debug('[context.topics] effect trig', topics)
// console.debug('[context.topics] effect trig', topics)
switch (sortAllBy()) {
case 'followers': {
topics.sort(byTopicStatDesc('followers'))

View File

@ -1,9 +1,8 @@
import { RouteDefinition, RouteLoadFuncArgs, type RouteSectionProps, createAsync } from '@solidjs/router'
import { Suspense, createEffect } from 'solid-js'
import { Suspense } from 'solid-js'
import { AllAuthors } from '~/components/Views/AllAuthors'
import { Loading } from '~/components/_shared/Loading'
import { PageLayout } from '~/components/_shared/PageLayout'
import { useAuthors } from '~/context/authors'
import { useLocalize } from '~/context/localize'
import { ReactionsProvider } from '~/context/reactions'
import { loadAuthors } from '~/graphql/api/public'
@ -48,9 +47,7 @@ export const route = {
export default function AllAuthorsPage(props: RouteSectionProps<{ authors: Author[] }>) {
const { t } = useLocalize()
const authors = createAsync<Author[]>(async () => props.data.authors || (await fetchData()) || [])
const { addAuthors } = useAuthors()
createEffect(() => addAuthors(authors() || []))
const authors = createAsync<Author[]>(async () => props.data.authors || await fetchData())
return (
<PageLayout withPadding={true} title={`${t('Discours')} :: ${t('All authors')}`}>
<ReactionsProvider>