From b44008b22972b2c7146d5e6d9983b941148f0d4f Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Thu, 14 Mar 2024 09:22:43 +0300 Subject: [PATCH] [WIP] --- public/locales/en/translation.json | 4 +- public/locales/ru/translation.json | 4 +- src/components/App.tsx | 1 + .../Author/AuthorCard/AuthorCard.tsx | 24 +++++----- src/components/Views/Author/Author.tsx | 28 +++++------- .../ProfileSubscriptions.tsx | 2 + src/context/following.tsx | 44 ++++++++----------- 7 files changed, 48 insertions(+), 59 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 7c097558..86a191f6 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -527,5 +527,7 @@ "yesterday": "yesterday", "Failed to delete comment": "Failed to delete comment", "It's OK. Just enter your email to receive a link to change your password": "It's OK. Just enter your email to receive a link to change your password", - "Restore password": "Restore password" + "Restore password": "Restore password", + "Subscribing...": "Subscribing...", + "Unsubscribing...": "Unsubscribing..." } diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 6dfe2bbd..8a7d26c8 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -554,5 +554,7 @@ "yesterday": "вчера", "Failed to delete comment": "Не удалось удалить комментарий", "It's OK. Just enter your email to receive a link to change your password": "Ничего страшного. Просто укажите свою почту, чтобы получить ссылку для смены пароля", - "Restore password": "Восстановить пароль" + "Restore password": "Восстановить пароль", + "Subscribing...": "Подписываем...", + "Unsubscribing...": "Отписываем..." } diff --git a/src/components/App.tsx b/src/components/App.tsx index c595ec15..7ad43757 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -39,6 +39,7 @@ import { InboxPage } from '../pages/inbox.page' import { HomePage } from '../pages/index.page' import { ProfileSecurityPage } from '../pages/profile/profileSecurity.page' import { ProfileSettingsPage } from '../pages/profile/profileSettings.page' +//TODO: ProfileSubscriptionsPage - garbage code? import { ProfileSubscriptionsPage } from '../pages/profile/profileSubscriptions.page' import { SearchPage } from '../pages/search.page' import { TopicPage } from '../pages/topic.page' diff --git a/src/components/Author/AuthorCard/AuthorCard.tsx b/src/components/Author/AuthorCard/AuthorCard.tsx index 6b67215a..ef2edb3f 100644 --- a/src/components/Author/AuthorCard/AuthorCard.tsx +++ b/src/components/Author/AuthorCard/AuthorCard.tsx @@ -34,7 +34,6 @@ export const AuthorCard = (props: Props) => { const { author, isSessionLoaded, requireAuthentication } = useSession() const [authorSubs, setAuthorSubs] = createSignal>([]) const [subscriptionFilter, setSubscriptionFilter] = createSignal('all') - const [isFollowed, setIsFollowed] = createSignal() const isProfileOwner = createMemo(() => author()?.slug === props.author.slug) const { follow, isOwnerSubscribed, subscribeInAction } = useFollowing() @@ -42,9 +41,10 @@ export const AuthorCard = (props: Props) => { setAuthorSubs(props.following) }) + const isSubscribed = isOwnerSubscribed(props.author?.id) + createEffect(() => { - console.log("!!! isOwnerSubscribed(props.author?.id):", isOwnerSubscribed(props.author?.id)); - setIsFollowed(isOwnerSubscribed(props.author?.id)) + console.log('%c!!! isSubscribed:', 'color: #bada55', isSubscribed()) }) const name = createMemo(() => { @@ -88,9 +88,7 @@ export const AuthorCard = (props: Props) => { }) const handleFollowClick = () => { console.log("!!! handleFollowClick:"); - const value = !isFollowed() requireAuthentication(() => { - setIsFollowed(value) follow(FollowingEntity.Author, props.author.slug) }, 'subscribe') } @@ -101,7 +99,7 @@ export const AuthorCard = (props: Props) => { return subscribeInAction().type === 'subscribe' ? t('Subscribing...') : t('Unsubscribing...') } - if (isOwnerSubscribed(props.author?.id)) { + if (isSubscribed()) { return ( <> {t('Following')} @@ -130,10 +128,7 @@ export const AuthorCard = (props: Props) => {
0) || - (props.following && props.following.length > 0) - } + when={(props.followers?.length > 0) || (props.following?.length > 0)} >
0}> @@ -213,10 +208,11 @@ export const AuthorCard = (props: Props) => {