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