Fix reload page after foute from profile to another profile (#430)

This commit is contained in:
Ilya Y 2024-03-25 16:07:14 +03:00 committed by GitHub
parent e3c00cc6cd
commit b84e7f43f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 23 deletions

View File

@ -29,8 +29,6 @@ import stylesArticle from '../../Article/Article.module.scss'
import styles from './Author.module.scss' import styles from './Author.module.scss'
type Props = { type Props = {
shouts: Shout[]
author: Author
authorSlug: string authorSlug: string
} }
export const PRERENDERED_ARTICLES_COUNT = 12 export const PRERENDERED_ARTICLES_COUNT = 12
@ -39,8 +37,8 @@ const LOAD_MORE_PAGE_SIZE = 9
export const AuthorView = (props: Props) => { export const AuthorView = (props: Props) => {
const { t } = useLocalize() const { t } = useLocalize()
const { loadSubscriptions } = useFollowing() const { loadSubscriptions } = useFollowing()
const { sortedArticles } = useArticlesStore({ shouts: props.shouts }) const { sortedArticles } = useArticlesStore()
const { authorEntities } = useAuthorsStore({ authors: [props.author] }) const { authorEntities } = useAuthorsStore()
const { page: getPage, searchParams } = useRouter() const { page: getPage, searchParams } = useRouter()
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
const [isBioExpanded, setIsBioExpanded] = createSignal(false) const [isBioExpanded, setIsBioExpanded] = createSignal(false)
@ -200,10 +198,10 @@ export const AuthorView = (props: Props) => {
</ul> </ul>
</div> </div>
<div class={clsx('col-md-8', styles.additionalControls)}> <div class={clsx('col-md-8', styles.additionalControls)}>
<Show when={props.author?.stat?.rating || props.author?.stat?.rating === 0}> <Show when={author()?.stat?.rating || author()?.stat?.rating === 0}>
<div class={styles.ratingContainer}> <div class={styles.ratingContainer}>
{t('All posts rating')} {t('All posts rating')}
<AuthorShoutsRating author={props.author} class={styles.ratingControl} /> <AuthorShoutsRating author={author()} class={styles.ratingControl} />
</div> </div>
</Show> </Show>
</div> </div>

View File

@ -56,17 +56,11 @@ export const AuthorPage = (props: PageProps) => {
onCleanup(() => resetSortedArticles()) onCleanup(() => resetSortedArticles())
const usePrerenderedData = props.author?.slug === slug()
return ( return (
<PageLayout title={props.seo?.title || t('Discours')}> <PageLayout title={props.seo?.title || t('Discours')}>
<ReactionsProvider> <ReactionsProvider>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<AuthorView <AuthorView authorSlug={slug()} />
author={usePrerenderedData ? props.author : null}
shouts={usePrerenderedData ? props.authorShouts : null}
authorSlug={slug()}
/>
</Show> </Show>
</ReactionsProvider> </ReactionsProvider>
</PageLayout> </PageLayout>