From 9e5b4689145f9e0d33e32b59e6993c7a7780ac80 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Thu, 5 Oct 2023 07:24:01 +0300 Subject: [PATCH] modify user query (#248) --- .../Author/AuthorBadge/AuthorBadge.tsx | 18 +++++++++++------- src/graphql/query/article-load.ts | 1 + src/graphql/query/author-followers.ts | 1 + src/graphql/query/author-following-users.ts | 1 + src/graphql/query/authors-all.ts | 1 + src/graphql/query/authors-load-by.ts | 2 +- src/graphql/query/drafts-load.ts | 1 + src/graphql/query/my-feed.ts | 1 + src/graphql/query/reactions-load-by.ts | 1 + 9 files changed, 19 insertions(+), 8 deletions(-) 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)} /> } >