2022-09-13 09:59:04 +00:00
|
|
|
|
import { For } from 'solid-js'
|
|
|
|
|
import type { Author } from '../../graphql/types.gen'
|
2022-09-30 14:22:33 +00:00
|
|
|
|
import { useAuthStore } from '../../stores/auth'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
import { useAuthorsStore } from '../../stores/zine/authors'
|
|
|
|
|
import { t } from '../../utils/intl'
|
2022-09-22 09:37:49 +00:00
|
|
|
|
import { Icon } from '../Nav/Icon'
|
2022-09-13 09:59:04 +00:00
|
|
|
|
import { useTopicsStore } from '../../stores/zine/topics'
|
|
|
|
|
import { useArticlesStore } from '../../stores/zine/articles'
|
|
|
|
|
import { useSeenStore } from '../../stores/zine/seen'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
|
|
type FeedSidebarProps = {
|
|
|
|
|
authors: Author[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const FeedSidebar = (props: FeedSidebarProps) => {
|
2022-09-13 09:59:04 +00:00
|
|
|
|
const { getSeen: seen } = useSeenStore()
|
2022-09-30 14:22:33 +00:00
|
|
|
|
const { session } = useAuthStore()
|
2022-09-28 20:16:44 +00:00
|
|
|
|
const { authorEntities } = useAuthorsStore({ authors: props.authors })
|
|
|
|
|
const { articlesByTopic } = useArticlesStore()
|
|
|
|
|
const { topicEntities } = useTopicsStore()
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
2022-09-13 09:59:04 +00:00
|
|
|
|
const checkTopicIsSeen = (topicSlug: string) => {
|
2022-09-28 20:16:44 +00:00
|
|
|
|
return articlesByTopic()[topicSlug].every((article) => Boolean(seen()[article.slug]))
|
2022-09-13 09:59:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const checkAuthorIsSeen = (authorSlug: string) => {
|
|
|
|
|
return Boolean(seen()[authorSlug])
|
|
|
|
|
}
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">
|
|
|
|
|
<strong>Мои дискуссии</strong>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">
|
|
|
|
|
<strong>Помощь сообществу</strong>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">Редактирование</a>
|
|
|
|
|
<span class="counter">7</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">Поделиться историей</a>
|
|
|
|
|
<span class="counter">18</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">Проголосовать</a>
|
|
|
|
|
<span class="counter">283</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="#">Подписки на форуме</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<a href="/feed?by=subscribed">
|
|
|
|
|
<strong>{t('My subscriptions')}</strong>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
|
2022-09-30 14:22:33 +00:00
|
|
|
|
<For each={session()?.info?.authors}>
|
2022-09-13 09:59:04 +00:00
|
|
|
|
{(authorSlug) => (
|
|
|
|
|
<li>
|
|
|
|
|
<a href={`/author/${authorSlug}`} classList={{ unread: checkAuthorIsSeen(authorSlug) }}>
|
|
|
|
|
<small>@{authorSlug}</small>
|
2022-09-28 20:16:44 +00:00
|
|
|
|
{authorEntities()[authorSlug].name}
|
2022-09-13 09:59:04 +00:00
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
|
2022-09-30 14:22:33 +00:00
|
|
|
|
<For each={session()?.info?.topics}>
|
2022-09-13 09:59:04 +00:00
|
|
|
|
{(topicSlug) => (
|
|
|
|
|
<li>
|
|
|
|
|
<a href={`/author/${topicSlug}`} classList={{ unread: checkTopicIsSeen(topicSlug) }}>
|
2022-09-28 20:16:44 +00:00
|
|
|
|
{topicEntities()[topicSlug]?.title}
|
2022-09-13 09:59:04 +00:00
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
2022-09-09 11:53:35 +00:00
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<p class="settings">
|
|
|
|
|
<a href="/feed/settings">
|
|
|
|
|
<strong>{t('Feed settings')}</strong>
|
|
|
|
|
</a>
|
|
|
|
|
<Icon name="settings" />
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|