import type { Topic } from '../../graphql/schema/core.gen' import { clsx } from 'clsx' import { Show, createEffect, createSignal } from 'solid-js' import { useFollowing } from '../../context/following' import { useLocalize } from '../../context/localize' import { useSession } from '../../context/session' import { FollowingEntity } from '../../graphql/schema/core.gen' import { Button } from '../_shared/Button' import styles from './Full.module.scss' type Props = { topic: Topic } export const FullTopic = (props: Props) => { const { t } = useLocalize() const { subscriptions, setFollowing } = useFollowing() const { actions: { requireAuthentication }, } = useSession() const [followed, setFollowed] = createSignal() createEffect(() => { const subs = subscriptions if (subs?.topics.length !== 0) { const items = subs.topics || [] setFollowed(items.some((x: Topic) => x?.slug === props.topic?.slug)) } }) const handleFollowClick = (_ev) => { const really = !followed() setFollowed(really) requireAuthentication(() => { setFollowing(FollowingEntity.Topic, props.topic.slug, really) }, 'follow') } return (
) }