diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index c2414246..39285612 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -17,9 +17,8 @@ type Props = { export const AuthorBadge = (props: Props) => { const [isSubscribing, setIsSubscribing] = createSignal(false) const { - isAuthenticated, session, - actions: { loadSession } + actions: { loadSession, requireAuthentication } } = useSession() const { t } = useLocalize() @@ -37,6 +36,11 @@ export const AuthorBadge = (props: Props) => { await loadSession() setIsSubscribing(false) } + const handleSubscribe = (really: boolean) => { + requireAuthentication(() => { + subscribe(really) + }, 'subscribe') + } return (
@@ -51,10 +55,10 @@ export const AuthorBadge = (props: Props) => {
} > -
{props.author.bio}
+
- +
{ subscribe(!subscribed)} + onClick={() => handleSubscribe(!subscribed())} /> } > @@ -73,15 +77,15 @@ export const AuthorBadge = (props: Props) => { variant="primary" size="S" value={isSubscribing() ? t('...subscribing') : t('Subscribe')} - onClick={() => subscribe(true)} + onClick={() => handleSubscribe(true)} /> } >