diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index be271c16..59ba9773 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -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() diff --git a/src/stores/zine/authors.ts b/src/stores/zine/authors.ts index 4744d74a..aa468a49 100644 --- a/src/stores/zine/authors.ts +++ b/src/stores/zine/authors.ts @@ -56,8 +56,14 @@ export const addAuthors = (authors: Author[]) => { ) } -export const loadAuthor = async ({ slug }: { slug: string }): Promise => { - const author = await apiClient.getAuthor({ slug }) +export const loadAuthor = async ({ + slug, + author_id, +}: { + slug: string + author_id: number +}): Promise => { + const author = await apiClient.getAuthor({ slug, author_id }) addAuthors([author]) return author }