import { clsx } from 'clsx' import styles from './TopicBadge.module.scss' import { FollowingEntity, Topic } from '../../../graphql/types.gen' import { createMemo, createSignal, Show } from 'solid-js' import { Button } from '../../_shared/Button' import { useSession } from '../../../context/session' import { useLocalize } from '../../../context/localize' import { follow, unfollow } from '../../../stores/zine/common' import { CheckButton } from '../../_shared/CheckButton' import { getImageUrl } from '../../../utils/getImageUrl' type Props = { topic: Topic minimizeSubscribeButton?: boolean } export const TopicBadge = (props: Props) => { const [isSubscribing, setIsSubscribing] = createSignal(false) const { t } = useLocalize() const { isAuthenticated, subscriptions, actions: { loadSubscriptions } } = useSession() const subscribed = createMemo(() => subscriptions().topics.some((topic) => topic.slug === props.topic.slug) ) const subscribe = async (really = true) => { setIsSubscribing(true) await (really ? follow({ what: FollowingEntity.Topic, slug: props.topic.slug }) : unfollow({ what: FollowingEntity.Topic, slug: props.topic.slug })) await loadSubscriptions() setIsSubscribing(false) } return (
} >