import { createEffect, createSignal, For, onMount, Show } from 'solid-js' import { Icon } from '../_shared/Icon' import { ArticleCard } from '../Feed/ArticleCard' import { AuthorCard } from '../Author/AuthorCard' import { Sidebar } from '../Feed/Sidebar' import { loadShouts, useArticlesStore } from '../../stores/zine/articles' import { useAuthorsStore } from '../../stores/zine/authors' import { useTopicsStore } from '../../stores/zine/topics' import { useTopAuthorsStore } from '../../stores/zine/topAuthors' import { useSession } from '../../context/session' import { clsx } from 'clsx' import { useReactions } from '../../context/reactions' import type { Author, Reaction } from '../../graphql/types.gen' import { getPagePath } from '@nanostores/router' import { router } from '../../stores/router' import { useLocalize } from '../../context/localize' import styles from './Feed.module.scss' import stylesTopic from '../Feed/CardTopic.module.scss' import stylesBeside from '../../components/Feed/Beside.module.scss' import { CommentDate } from '../Article/CommentDate' export const FEED_PAGE_SIZE = 20 export const FeedView = () => { const { t } = useLocalize() // state const { sortedArticles } = useArticlesStore() const { sortedAuthors } = useAuthorsStore() const { topTopics } = useTopicsStore() const { topAuthors } = useTopAuthorsStore() const { session, user } = useSession() const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const [topComments, setTopComments] = createSignal([]) const { actions: { loadReactionsBy } } = useReactions() // TODO: // const collaborativeShouts = createMemo(() => // sortedArticles().filter((shout) => shout.visibility === 'authors') // ) // createEffect(async () => { // if (collaborativeShouts()) { // await loadReactionsBy({ by: { shouts: collaborativeShouts().map((shout) => shout.slug) }, limit: 5 }) // } // }) createEffect(async () => { if (user()) { // load recent editing shouts ( visibility = authors ) await loadShouts({ filters: { author: user().slug, visibility: 'authors' }, limit: 15 }) } }) const loadMore = async () => { const { hasMore, newShouts } = await loadShouts({ filters: { visibility: 'community' }, limit: FEED_PAGE_SIZE, offset: sortedArticles().length }) loadReactionsBy({ by: { shouts: newShouts.map((s) => s.slug) } }) setIsLoadMoreButtonVisible(hasMore) } onMount(async () => { // load recent shouts not only published ( visibility = community ) await loadMore() // load 5 recent comments overall const comments = await loadReactionsBy({ by: { comment: true }, limit: 5 }) setTopComments(comments) }) return (
0}> {(article) => }

{t('Popular authors')}

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

) }