import { A, createAsync, useLocation, useNavigate, useSearchParams } from '@solidjs/router' import { clsx } from 'clsx' import { For, Show, createEffect, createMemo, createSignal, on } from 'solid-js' import { DropDown } from '~/components/_shared/DropDown' import { Option } from '~/components/_shared/DropDown/DropDown' import { Icon } from '~/components/_shared/Icon' import { InviteMembers } from '~/components/_shared/InviteMembers' import { Loading } from '~/components/_shared/Loading' import { ShareModal } from '~/components/_shared/ShareModal' import { useAuthors } from '~/context/authors' import { useGraphQL } from '~/context/graphql' import { useLocalize } from '~/context/localize' import { useReactions } from '~/context/reactions' import { useSession } from '~/context/session' import { useTopics } from '~/context/topics' import { useUI } from '~/context/ui' import { loadUnratedShouts } from '~/graphql/api/private' import type { Author, Reaction, Shout } from '~/graphql/schema/core.gen' import { byCreated } from '~/lib/sort' import { FeedSearchParams } from '~/routes/feed/(feed)' import { CommentDate } from '../../Article/CommentDate' import { getShareUrl } from '../../Article/SharePopup' import { AuthorBadge } from '../../Author/AuthorBadge' import { AuthorLink } from '../../Author/AuthorLink' import { ArticleCard } from '../../Feed/ArticleCard' import stylesBeside from '../../Feed/Beside.module.scss' import stylesTopic from '../../Feed/CardTopic.module.scss' import { Placeholder } from '../../Feed/Placeholder' import { Sidebar } from '../../Feed/Sidebar' import { Modal } from '../../Nav/Modal' import styles from './Feed.module.scss' export const FEED_PAGE_SIZE = 20 export type PeriodType = 'week' | 'month' | 'year' export type FeedProps = { shouts: Shout[] } export const FeedView = (props: FeedProps) => { const { t } = useLocalize() const loc = useLocation() const client = useGraphQL() const unrated = createAsync(async () => { if (client) { const shoutsLoader = loadUnratedShouts(client, { limit: 5 }) return await shoutsLoader() } }) const navigate = useNavigate() const { showModal } = useUI() const [isLoading, setIsLoading] = createSignal(false) const [isRightColumnLoaded, setIsRightColumnLoaded] = createSignal(false) const { session } = useSession() const { loadReactionsBy } = useReactions() const { topTopics } = useTopics() const { topAuthors } = useAuthors() const [topComments, setTopComments] = createSignal([]) const [searchParams, changeSearchParams] = useSearchParams() const asOption = (o: string) => ({ value: o, title: t(o) }) const asOptions = (opts: string[]) => opts.map(asOption) const currentPeriod = createMemo(() => asOption(searchParams?.period || '')) const loadTopComments = async () => { const comments = await loadReactionsBy({ by: { comment: true }, limit: 50 }) setTopComments(comments.sort(byCreated).reverse()) } createEffect( on( () => props.shouts, (sss: Shout[]) => { if (sss) { setIsLoading(true) Promise.all([ loadTopComments(), loadReactionsBy({ by: { shouts: sss.map((s: Shout) => s.slug) } }) ]).finally(() => { setIsRightColumnLoaded(true) setIsLoading(false) }) } }, { defer: true } ) ) const [shareData, setShareData] = createSignal() const handleShare = (shared: Shout | undefined) => { showModal('share') setShareData(shared) } return (
  • {t('Recent')}
  • {/*
  • */} {/* {t('Most read')}*/} {/*
  • */}
  • changeSearchParams({ by: 'likes' })}> {t('Top rated')}
  • changeSearchParams({ by: 'last_comment' })}> {t('Commented')}
changeSearchParams({ period: period.value })} /> navigate(`/feed/${mode.value}`)} />
}> 0}> {(article) => ( handleShare(shared)} onInvite={() => showModal('inviteMembers')} article={article} settings={{ isFeedMode: true }} desktopCoverSize="M" /> )}

{t('Popular authors')}

{t('All authors')}
    {(author) => (
  • )}
{(article) => ( )}
) }