trybyid
This commit is contained in:
parent
5f0ab7d870
commit
7ac836e4e3
|
@ -47,8 +47,8 @@ export const AuthorView = (props: Props) => {
|
||||||
const author = createMemo(() => authorEntities()[props.authorSlug])
|
const author = createMemo(() => authorEntities()[props.authorSlug])
|
||||||
|
|
||||||
createEffect(async () => {
|
createEffect(async () => {
|
||||||
if (!author()?.stat) {
|
if (author() && author().id && !author().stat) {
|
||||||
const a = await loadAuthor({ slug: props.authorSlug })
|
const a = await loadAuthor({ slug: '', author_id: author().id })
|
||||||
console.debug(`[AuthorView] loaded author:`, a)
|
console.debug(`[AuthorView] loaded author:`, a)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -78,8 +78,7 @@ export const AuthorView = (props: Props) => {
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
checkBioHeight()
|
checkBioHeight()
|
||||||
const slug = props.authorSlug || props.author.slug || author().slug
|
|
||||||
await loadAuthor({ slug })
|
|
||||||
// pagination
|
// pagination
|
||||||
if (sortedArticles().length === PRERENDERED_ARTICLES_COUNT) {
|
if (sortedArticles().length === PRERENDERED_ARTICLES_COUNT) {
|
||||||
await loadMore()
|
await loadMore()
|
||||||
|
|
|
@ -56,8 +56,14 @@ export const addAuthors = (authors: Author[]) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadAuthor = async ({ slug }: { slug: string }): Promise<Author> => {
|
export const loadAuthor = async ({
|
||||||
const author = await apiClient.getAuthor({ slug })
|
slug,
|
||||||
|
author_id,
|
||||||
|
}: {
|
||||||
|
slug: string
|
||||||
|
author_id: number
|
||||||
|
}): Promise<Author> => {
|
||||||
|
const author = await apiClient.getAuthor({ slug, author_id })
|
||||||
addAuthors([author])
|
addAuthors([author])
|
||||||
return author
|
return author
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user