diff --git a/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx b/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx index 8e5abd08..9abf237b 100644 --- a/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx +++ b/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx @@ -50,7 +50,7 @@ export const PasswordField = (props: Props) => { on( () => error(), () => { - props.errorMessage(error()) + props.errorMessage ?? props.errorMessage(error()) }, { defer: true }, ), diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index 2b274940..9aa79635 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -55,7 +55,6 @@ export const HeaderAuth = (props: Props) => { } const isEditorPage = createMemo(() => page().route === 'edit' || page().route === 'editSettings') - const isNotificationsVisible = createMemo(() => isAuthenticated() && !isEditorPage()) const isSaveButtonVisible = createMemo(() => isAuthenticated() && isEditorPage()) const isCreatePostButtonVisible = createMemo(() => isAuthenticated() && !isEditorPage()) diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index 0f704d14..b584fe6f 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -45,15 +45,12 @@ export const AuthorView = (props: Props) => { const [followers, setFollowers] = createSignal([]) const [following, setFollowing] = createSignal>([]) const [showExpandBioControl, setShowExpandBioControl] = createSignal(false) - const { - actions: { loadSubscriptions }, - } = useSession() const author = createMemo(() => authorEntities()[props.authorSlug]) createEffect(async () => { if (!author()?.stat) { - console.debug(`[AuthorView] updating author...`) - await loadAuthor({ slug: props.authorSlug }) + const a = await loadAuthor({ slug: props.authorSlug }) + console.debug(`[AuthorView] loaded author:`, a) } }) @@ -96,8 +93,8 @@ export const AuthorView = (props: Props) => { try { const { authors, topics } = await fetchSubscriptions() setFollowing([...(authors || []), ...(topics || [])]) - const userSubscribers = await loadSubscriptions() - setFollowers(userSubscribers) + const userSubscribers = await apiClient.getAuthorFollowers({ slug }) + setFollowers(userSubscribers || []) } catch (error) { console.error('[AuthorView] error:', error) } diff --git a/src/context/session.tsx b/src/context/session.tsx index 8d12a0dc..03e1331e 100644 --- a/src/context/session.tsx +++ b/src/context/session.tsx @@ -27,7 +27,7 @@ import { apiClient } from '../graphql/client/core' import { notifierClient } from '../graphql/client/notifier' import { useRouter } from '../stores/router' import { showModal } from '../stores/ui' - +import { addAuthors } from '../stores/zine/authors' import { useLocalize } from './localize' import { useSnackbar } from './snackbar' @@ -122,9 +122,7 @@ export const SessionProvider = (props: { }, ) - onCleanup(() => { - clearTimeout(ta) - }) + onCleanup(() => clearTimeout(ta)) const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource( async () => { @@ -156,7 +154,12 @@ export const SessionProvider = (props: { } if (!author()) { const a = await loadAuthor() - a ? await loadSubscriptions() : reset() + if (a) { + await loadSubscriptions() + addAuthors([a]) + } else { + reset() + } } setIsSessionLoaded(true) } diff --git a/src/stores/zine/authors.ts b/src/stores/zine/authors.ts index 0652b291..bac4523a 100644 --- a/src/stores/zine/authors.ts +++ b/src/stores/zine/authors.ts @@ -33,7 +33,7 @@ const sortedAuthors = createLazyMemo(() => { return authors }) -const addAuthors = (authors: Author[]) => { +export const addAuthors = (authors: Author[]) => { const newAuthorEntities = authors.filter(Boolean).reduce( (acc, author) => { acc[author.slug] = author