From 75caee909e48c83def9ca5b0190d2621a6870cd5 Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Tue, 12 Mar 2024 11:52:39 +0300 Subject: [PATCH] [WIP] --- src/components/Nav/AuthModal/LoginForm.tsx | 2 +- .../AuthModal/PasswordField/PasswordField.tsx | 2 +- src/context/following.tsx | 22 +++++++++++++------ src/graphql/client/core.ts | 2 +- src/graphql/mutation/core/follow.ts | 4 ++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/Nav/AuthModal/LoginForm.tsx b/src/components/Nav/AuthModal/LoginForm.tsx index 4ea5a5f6..1c4c774d 100644 --- a/src/components/Nav/AuthModal/LoginForm.tsx +++ b/src/components/Nav/AuthModal/LoginForm.tsx @@ -156,7 +156,7 @@ export const LoginForm = () => { handlePasswordInput(value)} + onBlur={(value) => handlePasswordInput(value)} /> diff --git a/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx b/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx index bf7f00b1..5c11b8ad 100644 --- a/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx +++ b/src/components/Nav/AuthModal/PasswordField/PasswordField.tsx @@ -12,7 +12,7 @@ type Props = { placeholder?: string errorMessage?: (error: string) => void setError?: string - onInput: (value: string) => void + onInput?: (value: string) => void onBlur?: (value: string) => void variant?: 'login' | 'registration' disableAutocomplete?: boolean diff --git a/src/context/following.tsx b/src/context/following.tsx index 5bab5f61..b722a61d 100644 --- a/src/context/following.tsx +++ b/src/context/following.tsx @@ -50,9 +50,11 @@ export const FollowingProvider = (props: { children: JSX.Element }) => { try { if (apiClient.private) { console.debug('[context.following] fetching subs data...') + console.log("%c!!! session()?.user.id:", 'background: #222; color: #bada55', session()); + const result = await apiClient.getAuthorFollows({ user: session()?.user.id }) + console.log("!!! result:", result); setSubscriptions(result || EMPTY_SUBSCRIPTIONS) - console.info('[context.following] subs:', subscriptions) } } catch (error) { console.info('[context.following] cannot get subs', error) @@ -61,8 +63,14 @@ export const FollowingProvider = (props: { children: JSX.Element }) => { } } + createEffect(() => { + console.info('[context.following] subs:', subscriptions); + }) + + const follow = async (what: FollowingEntity, slug: string) => { - console.log("!!! flw:", author()); + console.log("!!! follow what:", what); + console.log("!!! follow slug:", slug); // if (!author()) return setSubscribeInAction({ slug, type: 'subscribe' }) try { @@ -98,11 +106,11 @@ export const FollowingProvider = (props: { children: JSX.Element }) => { createEffect(() => { - console.log("!!! cone setSubscribeInAction:", subscribeInAction()); - if (author()) { - console.debug('[context.following] author update detect') - fetchData() - } + // console.log("!!! cone setSubscribeInAction:", subscribeInAction()); + // if (author()) { + // console.debug('[context.following] author update detect') + // fetchData() + // } }) const setFollowing = (what: FollowingEntity, slug: string, value = true) => { diff --git a/src/graphql/client/core.ts b/src/graphql/client/core.ts index 559540d3..b9c77ab6 100644 --- a/src/graphql/client/core.ts +++ b/src/graphql/client/core.ts @@ -92,7 +92,7 @@ export const apiClient = { follow: async ({ what, slug }: { what: FollowingEntity; slug: string }) => { const response = await apiClient.private.mutation(followMutation, { what, slug }).toPromise() - console.log("!!! response:", response); + console.log("!!! response FOLLOW AAAA:", 'background: #222; color: #bada55', response); return response.data.follow }, diff --git a/src/graphql/mutation/core/follow.ts b/src/graphql/mutation/core/follow.ts index 07ba6472..528dfd46 100644 --- a/src/graphql/mutation/core/follow.ts +++ b/src/graphql/mutation/core/follow.ts @@ -4,6 +4,10 @@ export default gql` mutation FollowMutation($what: FollowingEntity!, $slug: String!) { follow(what: $what, slug: $slug) { error + authors { + id + slug + } } } `