diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index b5c82c0e..6ca91c66 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -48,11 +48,19 @@ export const AuthorView = (props: Props) => { const [commented, setCommented] = createSignal() // current author - // const [author, _] = createSignal(props.author) + const [author, setAuthor] = createSignal() + createEffect(() => { + try { + const a = authorEntities()[props.authorSlug] + setAuthor(a) + } catch (error) { + console.debug(error) + } + }) createEffect(async () => { - if (props.author?.id && !props.author.stat) { - const a = await loadAuthor({ slug: '', author_id: props.author.id }) + if (author()?.id && !author().stat) { + const a = await loadAuthor({ slug: '', author_id: author().id }) console.debug('[AuthorView] loaded author:', a) } }) @@ -112,46 +120,42 @@ export const AuthorView = (props: Props) => { setCommented(data) } - createEffect( - on( - () => props.author, - () => { - fetchData(props.author) - fetchComments(props.author) - }, - { defer: true }, - ), - ) + createEffect(() => { + if (author()) { + fetchData(author()) + fetchComments(author()) + } + }) const ogImage = createMemo(() => - props.author?.pic - ? getImageUrl(props.author?.pic, { width: 1200 }) + author()?.pic + ? getImageUrl(author()?.pic, { width: 1200 }) : getImageUrl('production/image/logo_image.png'), ) - const description = createMemo(() => getDescription(props.author?.bio)) + const description = createMemo(() => getDescription(author()?.bio)) const handleDeleteComment = (id: number) => { setCommented((prev) => prev.filter((comment) => comment.id !== id)) } return (
- - {props.author.name} + + {author().name} - + - +
- }> + }> <>
- +
@@ -160,16 +164,16 @@ export const AuthorView = (props: Props) => { {t('Publications')} - - {props.author.stat.shouts} + + {author().stat.shouts}
  • {t('Comments')} - - {props.author.stat.comments} + + {author().stat.comments}
  • @@ -183,10 +187,10 @@ export const AuthorView = (props: Props) => {
  • - +
    {t('All posts rating')} - +
    @@ -205,7 +209,7 @@ export const AuthorView = (props: Props) => { class={styles.longBio} classList={{ [styles.longBioExpanded]: isBioExpanded() }} > -
    (bioContainerRef.current = el)} innerHTML={props.author.about} /> +
    (bioContainerRef.current = el)} innerHTML={author().about} />