diff --git a/src/components/Topic/Card.tsx b/src/components/Topic/Card.tsx index 4cd2d255..440a35bc 100644 --- a/src/components/Topic/Card.tsx +++ b/src/components/Topic/Card.tsx @@ -7,12 +7,10 @@ import { useSession } from '../../context/session' import { FollowingEntity, type Topic } from '../../graphql/schema/core.gen' import { capitalize } from '../../utils/capitalize' import { CardTopic } from '../Feed/CardTopic' -import { Button } from '../_shared/Button' import { CheckButton } from '../_shared/CheckButton' -import { Icon } from '../_shared/Icon' +import { FollowingButton } from '../_shared/FollowingButton' import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' -import stylesButton from '../_shared/Button/Button.module.scss' import styles from './Card.module.scss' interface TopicProps { @@ -38,20 +36,15 @@ export const TopicCard = (props: TopicProps) => { capitalize(lang() === 'en' ? props.topic.slug.replaceAll('-', ' ') : props.topic.title || ''), ) const { author, requireAuthentication } = useSession() - const [isFollowed, setIsFollowed] = createSignal() - const { follow, unfollow, follows, following } = useFollowing() - + const { follow, unfollow, follows } = useFollowing() + const [isFollowed, setIsFollowed] = createSignal(false) createEffect( - on( - [() => follows, () => props.topic], - ([flws, tpc]) => { - if (flws && tpc) { - const followed = flws.topics?.some((topics) => topics.id === props.topic?.id) - setIsFollowed(followed) - } - }, - { defer: true }, - ), + on([() => follows, () => props.topic], ([flws, tpc]) => { + if (flws && tpc) { + const followed = follows?.topics?.some((topics) => topics.id === props.topic?.id) + setIsFollowed(followed) + } + }), ) const handleFollowClick = () => { @@ -62,24 +55,6 @@ export const TopicCard = (props: TopicProps) => { }, 'follow') } - const subscribeValue = () => { - return ( - <> - - - - - - - - {t('Unfollow')} - {t('Following')} - - - - ) - } - return (
{ + } > -