2023-09-01 14:28:50 +00:00
|
|
|
|
import type { Author } from '../../../graphql/types.gen'
|
|
|
|
|
import { Userpic } from '../Userpic'
|
|
|
|
|
import { Icon } from '../../_shared/Icon'
|
2023-05-01 18:32:32 +00:00
|
|
|
|
import styles from './AuthorCard.module.scss'
|
2023-09-01 14:28:50 +00:00
|
|
|
|
import { createEffect, createMemo, createSignal, For, Show } from 'solid-js'
|
|
|
|
|
import { translit } from '../../../utils/ru2en'
|
|
|
|
|
import { follow, unfollow } from '../../../stores/zine/common'
|
2022-10-14 18:33:06 +00:00
|
|
|
|
import { clsx } from 'clsx'
|
2023-09-01 14:28:50 +00:00
|
|
|
|
import { useSession } from '../../../context/session'
|
|
|
|
|
import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient'
|
|
|
|
|
import { FollowingEntity, Topic } from '../../../graphql/types.gen'
|
|
|
|
|
import { router, useRouter } from '../../../stores/router'
|
2023-09-16 06:26:19 +00:00
|
|
|
|
import { openPage, redirectPage } from '@nanostores/router'
|
2023-09-01 14:28:50 +00:00
|
|
|
|
import { useLocalize } from '../../../context/localize'
|
|
|
|
|
import { ConditionalWrapper } from '../../_shared/ConditionalWrapper'
|
|
|
|
|
import { Modal } from '../../Nav/Modal'
|
|
|
|
|
import { showModal } from '../../../stores/ui'
|
|
|
|
|
import { TopicCard } from '../../Topic/Card'
|
|
|
|
|
import { getNumeralsDeclension } from '../../../utils/getNumeralsDeclension'
|
2023-09-18 16:33:22 +00:00
|
|
|
|
import { SubscriptionFilter } from '../../../pages/types'
|
|
|
|
|
import { isAuthor } from '../../../utils/isAuthor'
|
|
|
|
|
import { CheckButton } from '../../_shared/CheckButton'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
2023-09-09 12:04:46 +00:00
|
|
|
|
type Props = {
|
2022-11-19 05:00:54 +00:00
|
|
|
|
caption?: string
|
2023-03-23 21:39:13 +00:00
|
|
|
|
hideWriteButton?: boolean
|
2022-09-09 11:53:35 +00:00
|
|
|
|
hideDescription?: boolean
|
|
|
|
|
hideFollow?: boolean
|
|
|
|
|
hasLink?: boolean
|
|
|
|
|
subscribed?: boolean
|
|
|
|
|
author: Author
|
2022-10-14 18:33:06 +00:00
|
|
|
|
isAuthorPage?: boolean
|
2022-10-19 21:40:50 +00:00
|
|
|
|
noSocialButtons?: boolean
|
2022-11-11 08:58:22 +00:00
|
|
|
|
isAuthorsList?: boolean
|
2022-11-16 21:08:04 +00:00
|
|
|
|
truncateBio?: boolean
|
2022-11-23 19:14:59 +00:00
|
|
|
|
liteButtons?: boolean
|
2023-05-17 20:27:24 +00:00
|
|
|
|
isTextButton?: boolean
|
2022-11-26 21:27:54 +00:00
|
|
|
|
isComments?: boolean
|
2023-01-26 21:42:47 +00:00
|
|
|
|
isFeedMode?: boolean
|
2023-02-13 13:48:05 +00:00
|
|
|
|
isNowrap?: boolean
|
2023-06-02 22:01:34 +00:00
|
|
|
|
class?: string
|
2023-09-01 14:28:50 +00:00
|
|
|
|
followers?: Author[]
|
2023-09-16 06:26:19 +00:00
|
|
|
|
following?: Array<Author | Topic>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
showPublicationsCounter?: boolean
|
2023-09-18 16:33:22 +00:00
|
|
|
|
minimizeSubscribeButton?: boolean
|
2022-09-09 11:53:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-09 12:04:46 +00:00
|
|
|
|
export const AuthorCard = (props: Props) => {
|
2023-02-17 09:21:02 +00:00
|
|
|
|
const { t, lang } = useLocalize()
|
2023-09-16 06:26:19 +00:00
|
|
|
|
const { page } = useRouter()
|
2022-12-01 18:45:35 +00:00
|
|
|
|
const {
|
|
|
|
|
session,
|
2022-12-06 16:03:55 +00:00
|
|
|
|
isSessionLoaded,
|
2023-06-14 17:19:30 +00:00
|
|
|
|
actions: { loadSession, requireAuthentication }
|
2022-12-01 18:45:35 +00:00
|
|
|
|
} = useSession()
|
|
|
|
|
|
|
|
|
|
const [isSubscribing, setIsSubscribing] = createSignal(false)
|
2023-09-16 06:26:19 +00:00
|
|
|
|
const [following, setFollowing] = createSignal<Array<Author | Topic>>(props.following)
|
2023-09-01 14:28:50 +00:00
|
|
|
|
const [subscriptionFilter, setSubscriptionFilter] = createSignal<SubscriptionFilter>('all')
|
2023-09-09 12:04:46 +00:00
|
|
|
|
const [userpicUrl, setUserpicUrl] = createSignal<string>()
|
2022-09-30 14:22:33 +00:00
|
|
|
|
|
2023-01-20 04:40:55 +00:00
|
|
|
|
const subscribed = createMemo<boolean>(() => {
|
|
|
|
|
return session()?.news?.authors?.some((u) => u === props.author.slug) || false
|
|
|
|
|
})
|
2022-12-01 18:45:35 +00:00
|
|
|
|
|
|
|
|
|
const subscribe = async (really = true) => {
|
|
|
|
|
setIsSubscribing(true)
|
|
|
|
|
|
|
|
|
|
await (really
|
|
|
|
|
? follow({ what: FollowingEntity.Author, slug: props.author.slug })
|
|
|
|
|
: unfollow({ what: FollowingEntity.Author, slug: props.author.slug }))
|
|
|
|
|
|
|
|
|
|
await loadSession()
|
|
|
|
|
setIsSubscribing(false)
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 14:22:33 +00:00
|
|
|
|
const canFollow = createMemo(() => !props.hideFollow && session()?.user?.slug !== props.author.slug)
|
2022-11-21 00:12:20 +00:00
|
|
|
|
|
2022-12-07 20:11:32 +00:00
|
|
|
|
const name = createMemo(() => {
|
2023-02-17 09:21:02 +00:00
|
|
|
|
if (lang() !== 'ru') {
|
2022-12-07 20:11:32 +00:00
|
|
|
|
if (props.author.name === 'Дискурс') {
|
|
|
|
|
return 'Discours'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return translit(props.author.name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return props.author.name
|
|
|
|
|
})
|
|
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
|
// TODO: reimplement AuthorCard
|
2022-12-17 03:27:00 +00:00
|
|
|
|
const { changeSearchParam } = useRouter()
|
|
|
|
|
const initChat = () => {
|
2023-06-14 17:19:30 +00:00
|
|
|
|
requireAuthentication(() => {
|
|
|
|
|
openPage(router, `inbox`)
|
|
|
|
|
changeSearchParam('initChat', `${props.author.id}`)
|
|
|
|
|
}, 'discussions')
|
2022-12-17 03:27:00 +00:00
|
|
|
|
}
|
2023-06-14 17:19:30 +00:00
|
|
|
|
|
|
|
|
|
const handleSubscribe = () => {
|
|
|
|
|
requireAuthentication(() => {
|
|
|
|
|
subscribe(true)
|
|
|
|
|
}, 'subscribe')
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 14:28:50 +00:00
|
|
|
|
createEffect(() => {
|
2023-09-16 06:26:19 +00:00
|
|
|
|
if (props.following) {
|
2023-09-01 14:28:50 +00:00
|
|
|
|
if (subscriptionFilter() === 'users') {
|
2023-09-16 06:26:19 +00:00
|
|
|
|
setFollowing(props.following.filter((s) => 'name' in s))
|
2023-09-01 14:28:50 +00:00
|
|
|
|
} else if (subscriptionFilter() === 'topics') {
|
2023-09-16 06:26:19 +00:00
|
|
|
|
setFollowing(props.following.filter((s) => 'title' in s))
|
2023-09-01 14:28:50 +00:00
|
|
|
|
} else {
|
2023-09-16 06:26:19 +00:00
|
|
|
|
setFollowing(props.following)
|
2023-09-01 14:28:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2023-09-16 06:26:19 +00:00
|
|
|
|
createEffect(() => {
|
|
|
|
|
if (page().route === 'authorFollowing') {
|
|
|
|
|
showModal('following')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleCloseFollowModals = () => {
|
|
|
|
|
redirectPage(router, 'author', { slug: props.author.slug })
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 05:07:27 +00:00
|
|
|
|
if (props.isAuthorPage && props.author.userpic?.includes('assets.discours.io')) {
|
2023-09-09 12:04:46 +00:00
|
|
|
|
setUserpicUrl(props.author.userpic.replace('100x', '500x500'))
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
|
return (
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<>
|
2023-08-27 21:21:40 +00:00
|
|
|
|
<div
|
2023-09-02 22:14:34 +00:00
|
|
|
|
class={clsx(styles.author, props.class)}
|
2023-08-27 21:21:40 +00:00
|
|
|
|
classList={{
|
2023-09-02 22:14:34 +00:00
|
|
|
|
['row']: props.isAuthorPage,
|
|
|
|
|
[styles.authorPage]: props.isAuthorPage,
|
|
|
|
|
[styles.authorComments]: props.isComments,
|
|
|
|
|
[styles.authorsListItem]: props.isAuthorsList,
|
|
|
|
|
[styles.feedMode]: props.isFeedMode,
|
|
|
|
|
[styles.nowrapView]: props.isNowrap
|
2023-08-27 21:21:40 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<Show
|
|
|
|
|
when={props.isAuthorPage}
|
|
|
|
|
fallback={
|
|
|
|
|
<Userpic
|
|
|
|
|
name={props.author.name}
|
|
|
|
|
userpic={props.author.userpic}
|
|
|
|
|
hasLink={props.hasLink}
|
|
|
|
|
isBig={props.isAuthorPage}
|
|
|
|
|
isAuthorsList={props.isAuthorsList}
|
|
|
|
|
isFeedMode={props.isFeedMode}
|
2023-09-27 21:51:06 +00:00
|
|
|
|
slug={props.author.slug}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
class={styles.circlewrap}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div class="col-md-5">
|
|
|
|
|
<Userpic
|
|
|
|
|
name={props.author.name}
|
2023-09-09 12:04:46 +00:00
|
|
|
|
userpic={userpicUrl()}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
hasLink={props.hasLink}
|
|
|
|
|
isBig={props.isAuthorPage}
|
|
|
|
|
isAuthorsList={props.isAuthorsList}
|
|
|
|
|
isFeedMode={props.isFeedMode}
|
2023-09-27 21:51:06 +00:00
|
|
|
|
slug={props.author.slug}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
class={styles.circlewrap}
|
2022-12-01 18:45:35 +00:00
|
|
|
|
/>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
2022-11-30 21:50:33 +00:00
|
|
|
|
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<div
|
|
|
|
|
class={styles.authorDetails}
|
|
|
|
|
classList={{
|
|
|
|
|
'col-md-15 col-xl-13': props.isAuthorPage,
|
|
|
|
|
[styles.authorDetailsShrinked]: props.isAuthorPage
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class={styles.authorDetailsWrapper}>
|
|
|
|
|
<div class={styles.authorNameContainer}>
|
|
|
|
|
<ConditionalWrapper
|
|
|
|
|
condition={props.hasLink}
|
|
|
|
|
wrapper={(children) => (
|
|
|
|
|
<a class={styles.authorName} href={`/author/${props.author.slug}`}>
|
|
|
|
|
{children}
|
|
|
|
|
</a>
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<span class={clsx({ [styles.authorName]: !props.hasLink })}>{name()}</span>
|
|
|
|
|
</ConditionalWrapper>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</div>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
{/*TODO: implement plurals by i18n*/}
|
|
|
|
|
<Show
|
|
|
|
|
when={props.author.bio}
|
|
|
|
|
fallback={
|
|
|
|
|
props.showPublicationsCounter ? (
|
|
|
|
|
<div class={styles.authorAbout}>{props.author.stat?.shouts} публикаций</div>
|
|
|
|
|
) : (
|
|
|
|
|
''
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class={styles.authorAbout}
|
|
|
|
|
classList={{ 'text-truncate': props.truncateBio }}
|
|
|
|
|
innerHTML={props.author.bio}
|
|
|
|
|
/>
|
|
|
|
|
</Show>
|
|
|
|
|
|
|
|
|
|
<Show
|
|
|
|
|
when={
|
|
|
|
|
(props.followers && props.followers.length > 0) ||
|
2023-09-16 06:26:19 +00:00
|
|
|
|
(props.following && props.following.length > 0)
|
2023-09-02 22:14:34 +00:00
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div class={styles.subscribersContainer}>
|
|
|
|
|
<Show when={props.followers && props.followers.length > 0}>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<div
|
|
|
|
|
class={styles.subscribers}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
redirectPage(router, 'authorFollowers', { slug: props.author.slug })
|
|
|
|
|
showModal('followers')
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<For each={props.followers.slice(0, 3)}>
|
|
|
|
|
{(f) => <Userpic name={f.name} userpic={f.userpic} class={styles.userpic} />}
|
|
|
|
|
</For>
|
|
|
|
|
<div class={styles.subscribersCounter}>
|
|
|
|
|
{props.followers.length}
|
|
|
|
|
{getNumeralsDeclension(props.followers.length, [
|
|
|
|
|
t('subscriber'),
|
|
|
|
|
t('subscriber_rp'),
|
|
|
|
|
t('subscribers')
|
|
|
|
|
])}
|
|
|
|
|
</div>
|
2023-08-27 21:21:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<Show when={props.following && props.following.length > 0}>
|
|
|
|
|
<div
|
|
|
|
|
class={styles.subscribers}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
redirectPage(router, 'authorFollowing', { slug: props.author.slug })
|
|
|
|
|
showModal('following')
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<For each={props.following.slice(0, 3)}>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
{(f) => {
|
|
|
|
|
if ('name' in f) {
|
|
|
|
|
return <Userpic name={f.name} userpic={f.userpic} class={styles.userpic} />
|
|
|
|
|
} else if ('title' in f) {
|
|
|
|
|
return <Userpic name={f.title} userpic={f.pic} class={styles.userpic} />
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}}
|
|
|
|
|
</For>
|
|
|
|
|
<div class={styles.subscribersCounter}>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
{props.following.length}
|
|
|
|
|
{getNumeralsDeclension(props.following.length, [
|
2023-09-02 22:14:34 +00:00
|
|
|
|
t('subscription'),
|
|
|
|
|
t('subscription_rp'),
|
|
|
|
|
t('subscriptions')
|
|
|
|
|
])}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
<ShowOnlyOnClient>
|
|
|
|
|
<Show when={isSessionLoaded()}>
|
|
|
|
|
<Show when={canFollow()}>
|
|
|
|
|
<div class={styles.authorSubscribe}>
|
2023-09-27 22:21:27 +00:00
|
|
|
|
<Show when={!props.noSocialButtons && !props.hideWriteButton && props.author.links}>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<div class={styles.authorSubscribeSocial}>
|
|
|
|
|
<For each={props.author.links}>{(link) => <a href={link} />}</For>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
2023-09-18 16:33:22 +00:00
|
|
|
|
<Show when={!props.minimizeSubscribeButton}>
|
|
|
|
|
<Show
|
|
|
|
|
when={subscribed()}
|
|
|
|
|
fallback={
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleSubscribe}
|
|
|
|
|
class={clsx('button', styles.button)}
|
|
|
|
|
classList={{
|
|
|
|
|
[styles.buttonSubscribe]: !props.isAuthorsList && !props.isTextButton,
|
|
|
|
|
'button--subscribe': !props.isAuthorsList,
|
|
|
|
|
'button--subscribe-topic': props.isAuthorsList || props.isTextButton,
|
|
|
|
|
[styles.buttonWrite]: props.isAuthorsList || props.isTextButton,
|
|
|
|
|
[styles.isSubscribing]: isSubscribing()
|
|
|
|
|
}}
|
|
|
|
|
disabled={isSubscribing()}
|
|
|
|
|
>
|
|
|
|
|
<Show when={!props.isAuthorsList && !props.isTextButton && !props.isAuthorPage}>
|
|
|
|
|
<Icon name="author-subscribe" class={styles.icon} />
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={props.isTextButton || props.isAuthorPage}>
|
|
|
|
|
<span class={clsx(styles.buttonLabel, styles.buttonLabelVisible)}>
|
|
|
|
|
{t('Follow')}
|
|
|
|
|
</span>
|
|
|
|
|
</Show>
|
|
|
|
|
</button>
|
|
|
|
|
}
|
|
|
|
|
>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<button
|
2023-09-18 16:33:22 +00:00
|
|
|
|
onClick={() => subscribe(false)}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
class={clsx('button', styles.button)}
|
|
|
|
|
classList={{
|
|
|
|
|
[styles.buttonSubscribe]: !props.isAuthorsList && !props.isTextButton,
|
|
|
|
|
'button--subscribe': !props.isAuthorsList,
|
|
|
|
|
'button--subscribe-topic': props.isAuthorsList || props.isTextButton,
|
|
|
|
|
[styles.buttonWrite]: props.isAuthorsList || props.isTextButton,
|
|
|
|
|
[styles.isSubscribing]: isSubscribing()
|
|
|
|
|
}}
|
|
|
|
|
disabled={isSubscribing()}
|
|
|
|
|
>
|
|
|
|
|
<Show when={!props.isAuthorsList && !props.isTextButton && !props.isAuthorPage}>
|
2023-09-18 16:33:22 +00:00
|
|
|
|
<Icon name="author-unsubscribe" class={styles.icon} />
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</Show>
|
|
|
|
|
<Show when={props.isTextButton || props.isAuthorPage}>
|
2023-09-18 16:33:22 +00:00
|
|
|
|
<span
|
|
|
|
|
class={clsx(
|
|
|
|
|
styles.buttonLabel,
|
|
|
|
|
styles.buttonLabelVisible,
|
|
|
|
|
styles.buttonUnfollowLabel
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{t('Unfollow')}
|
|
|
|
|
</span>
|
|
|
|
|
<span
|
|
|
|
|
class={clsx(
|
|
|
|
|
styles.buttonLabel,
|
|
|
|
|
styles.buttonLabelVisible,
|
|
|
|
|
styles.buttonSubscribedLabel
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{t('You are subscribed')}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</span>
|
|
|
|
|
</Show>
|
|
|
|
|
</button>
|
2023-09-18 16:33:22 +00:00
|
|
|
|
</Show>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={props.minimizeSubscribeButton}>
|
|
|
|
|
<CheckButton
|
|
|
|
|
text={t('Follow')}
|
|
|
|
|
checked={subscribed()}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
onClick={() => subscribe(false)}
|
2023-09-18 16:33:22 +00:00
|
|
|
|
/>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</Show>
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<Show when={!props.hideWriteButton}>
|
|
|
|
|
<button
|
|
|
|
|
class={styles.button}
|
|
|
|
|
classList={{
|
|
|
|
|
[styles.buttonSubscribe]: !props.isAuthorsList,
|
|
|
|
|
'button--subscribe': !props.isAuthorsList,
|
|
|
|
|
'button--subscribe-topic': props.isAuthorsList,
|
|
|
|
|
[styles.buttonWrite]: props.liteButtons && props.isAuthorsList
|
|
|
|
|
}}
|
|
|
|
|
onClick={initChat}
|
|
|
|
|
>
|
|
|
|
|
<Show when={!props.isTextButton && !props.isAuthorPage}>
|
|
|
|
|
<Icon name="comment" class={styles.icon} />
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!props.liteButtons || props.isTextButton}>{t('Write')}</Show>
|
|
|
|
|
</button>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
2022-09-09 11:53:35 +00:00
|
|
|
|
</Show>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</ShowOnlyOnClient>
|
|
|
|
|
</div>
|
2022-10-04 12:42:11 +00:00
|
|
|
|
</div>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<Show when={props.followers}>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<Modal variant="wide" name="followers" onClose={handleCloseFollowModals} maxHeight>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<>
|
|
|
|
|
<h2>{t('Followers')}</h2>
|
|
|
|
|
<div class={styles.listWrapper}>
|
|
|
|
|
<div class="row">
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<div class="col-24">
|
|
|
|
|
<For each={props.followers}>
|
|
|
|
|
{(follower: Author) => (
|
|
|
|
|
<AuthorCard
|
|
|
|
|
author={follower}
|
|
|
|
|
hideWriteButton={true}
|
|
|
|
|
hasLink={true}
|
|
|
|
|
isTextButton={true}
|
|
|
|
|
liteButtons={true}
|
|
|
|
|
truncateBio={true}
|
|
|
|
|
showPublicationsCounter={true}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</div>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
</Modal>
|
|
|
|
|
</Show>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<Show when={props.following}>
|
|
|
|
|
<Modal variant="wide" name="following" onClose={handleCloseFollowModals} maxHeight>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<>
|
|
|
|
|
<h2>{t('Subscriptions')}</h2>
|
|
|
|
|
<ul class="view-switcher">
|
2023-09-01 14:46:07 +00:00
|
|
|
|
<li class={clsx({ 'view-switcher__item--selected': subscriptionFilter() === 'all' })}>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<button type="button" onClick={() => setSubscriptionFilter('all')}>
|
2023-09-06 22:55:16 +00:00
|
|
|
|
{t('All')}
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</button>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<span class={styles.switcherCounter}>{props.following.length}</span>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</li>
|
2023-09-01 14:46:07 +00:00
|
|
|
|
<li class={clsx({ 'view-switcher__item--selected': subscriptionFilter() === 'users' })}>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<button type="button" onClick={() => setSubscriptionFilter('users')}>
|
2023-09-06 22:55:16 +00:00
|
|
|
|
{t('Users')}
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</button>
|
2023-09-06 22:55:16 +00:00
|
|
|
|
<span class={styles.switcherCounter}>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
{props.following.filter((s) => 'name' in s).length}
|
2023-09-06 22:55:16 +00:00
|
|
|
|
</span>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</li>
|
2023-09-01 14:46:07 +00:00
|
|
|
|
<li class={clsx({ 'view-switcher__item--selected': subscriptionFilter() === 'topics' })}>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<button type="button" onClick={() => setSubscriptionFilter('topics')}>
|
2023-09-06 22:55:16 +00:00
|
|
|
|
{t('Topics')}
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</button>
|
2023-09-06 22:55:16 +00:00
|
|
|
|
<span class={styles.switcherCounter}>
|
2023-09-16 06:26:19 +00:00
|
|
|
|
{props.following.filter((s) => 'title' in s).length}
|
2023-09-06 22:55:16 +00:00
|
|
|
|
</span>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<br />
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<div class={styles.listWrapper}>
|
|
|
|
|
<div class="row">
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<div class="col-24">
|
2023-09-16 06:26:19 +00:00
|
|
|
|
<For each={following()}>
|
2023-09-18 16:33:22 +00:00
|
|
|
|
{(subscription) =>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
isAuthor(subscription) ? (
|
2023-09-01 14:28:50 +00:00
|
|
|
|
<AuthorCard
|
|
|
|
|
author={subscription}
|
|
|
|
|
hideWriteButton={true}
|
|
|
|
|
hasLink={true}
|
|
|
|
|
isTextButton={true}
|
2023-09-02 22:14:34 +00:00
|
|
|
|
truncateBio={true}
|
|
|
|
|
showPublicationsCounter={true}
|
2023-09-01 14:28:50 +00:00
|
|
|
|
/>
|
|
|
|
|
) : (
|
2023-09-02 22:14:34 +00:00
|
|
|
|
<TopicCard compact isTopicInRow showDescription isCardMode topic={subscription} />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</For>
|
|
|
|
|
</div>
|
2023-09-01 14:28:50 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
</Modal>
|
|
|
|
|
</Show>
|
2023-09-02 22:14:34 +00:00
|
|
|
|
</>
|
2022-09-09 11:53:35 +00:00
|
|
|
|
)
|
|
|
|
|
}
|