diff --git a/.eslintrc.js b/.eslintrc.js index c0284d22..6d38d919 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -77,7 +77,8 @@ module.exports = { eqeqeq: 'error', 'no-param-reassign': 'error', - 'no-nested-ternary': 'error' + 'no-nested-ternary': 'error', + 'no-shadow': 'error' }, settings: { 'import/resolver': { diff --git a/src/components/Feed/Card.tsx b/src/components/Feed/Card.tsx index c23e19a2..da9e33a6 100644 --- a/src/components/Feed/Card.tsx +++ b/src/components/Feed/Card.tsx @@ -72,113 +72,109 @@ export const ArticleCard = (props: ArticleCardProps) => { 'shout-card--feed': props.settings?.isFeedMode }} > - - -
-
- {title -
+ +
+
+ {title +
+
+
+ +
+ + -
- -
- - - -
-
- - - - - -
- -
- {title} -
- - -
- {subtitle} -
-
+ +
+ - -
- -
- - {(author, index) => { - const name = - author.name === 'Дискурс' && locale() !== 'ru' - ? 'Discours' - : translit(author.name || '', locale() || 'ru') - - return ( - <> - 0}>, - {name} - - ) - }} - -
-
- - -
{formattedDate()}
-
+
+ +
+ {title}
- - -
- -
- -
+ +
+ +
+ + {(author, index) => { + const name = + author.name === 'Дискурс' && locale() !== 'ru' + ? 'Discours' + : translit(author.name || '', locale() || 'ru') -
- -
+ return ( + <> + 0}>, + {name} + + ) + }} +
+
+
+ + +
{formattedDate()}
+
+
+
+ + +
+
+
+ + {stat?.rating || ''} + +
+
+ + {stat?.viewed} +
+ - -
-
-
- +
+ +
+ +
+ +
+
+ + + +
+
) } diff --git a/src/components/Feed/Sidebar.tsx b/src/components/Feed/Sidebar.tsx index 09cfc0ca..2df4d52c 100644 --- a/src/components/Feed/Sidebar.tsx +++ b/src/components/Feed/Sidebar.tsx @@ -16,12 +16,12 @@ type FeedSidebarProps = { export const FeedSidebar = (props: FeedSidebarProps) => { const { getSeen: seen } = useSeenStore() const auth = useStore(session) - const { getSortedAuthors: authors } = useAuthorsStore({ authors: props.authors }) - const { getArticlesByTopic } = useArticlesStore() - const { getTopicEntities } = useTopicsStore() + const { authorEntities } = useAuthorsStore({ authors: props.authors }) + const { articlesByTopic } = useArticlesStore() + const { topicEntities } = useTopicsStore() const checkTopicIsSeen = (topicSlug: string) => { - return getArticlesByTopic()[topicSlug].every((article) => Boolean(seen()[article.slug])) + return articlesByTopic()[topicSlug].every((article) => Boolean(seen()[article.slug])) } const checkAuthorIsSeen = (authorSlug: string) => { @@ -69,7 +69,7 @@ export const FeedSidebar = (props: FeedSidebarProps) => {
  • @{authorSlug} - {authors()[authorSlug].name} + {authorEntities()[authorSlug].name}
  • )} @@ -79,7 +79,7 @@ export const FeedSidebar = (props: FeedSidebarProps) => { {(topicSlug) => (
  • - {getTopicEntities()[topicSlug]?.title} + {topicEntities()[topicSlug]?.title}
  • )} diff --git a/src/components/Pages/ArticlePage.tsx b/src/components/Pages/ArticlePage.tsx index 773665c6..74c8a338 100644 --- a/src/components/Pages/ArticlePage.tsx +++ b/src/components/Pages/ArticlePage.tsx @@ -18,17 +18,17 @@ export const ArticlePage = (props: PageProps) => { throw new Error('ts guard') } - const { getArticleEntities } = useArticlesStore({ + const { articleEntities } = useArticlesStore({ sortedArticles }) - const article = createMemo(() => getArticleEntities()[page.params.slug]) + const article = createMemo(() => articleEntities()[page.params.slug]) onMount(() => { const slug = page.params.slug - const article = getArticleEntities()[slug] + const articleValue = articleEntities()[slug] - if (!article || !article.body) { + if (!articleValue || !articleValue.body) { loadArticle({ slug }) } }) diff --git a/src/components/Root.tsx b/src/components/Root.tsx index bd1c619c..11fd9a7c 100644 --- a/src/components/Root.tsx +++ b/src/components/Root.tsx @@ -9,36 +9,42 @@ import { getLogger } from '../utils/logger' import type { PageProps } from './types' -// do not remove -// for debugging, to disable lazy loading -// import HomePage from './Pages/HomePage' -// import AllTopicsPage from './Pages/AllTopicsPage' -// import TopicPage from './Pages/TopicPage' -// import AllAuthorsPage from './Pages/AllAuthorsPage' -// import AuthorPage from './Pages/AuthorPage' -// import FeedPage from './Pages/FeedPage' -// import ArticlePage from './Pages/ArticlePage' -// import SearchPage from './Pages/SearchPage' -// import FourOuFourPage from './Pages/FourOuFourPage' +import { HomePage } from './Pages/HomePage' +import { AllTopicsPage } from './Pages/AllTopicsPage' +import { TopicPage } from './Pages/TopicPage' +import { AllAuthorsPage } from './Pages/AllAuthorsPage' +import { AuthorPage } from './Pages/AuthorPage' +import { FeedPage } from './Pages/FeedPage' +import { ArticlePage } from './Pages/ArticlePage' +import { SearchPage } from './Pages/SearchPage' +import { FourOuFourPage } from './Pages/FourOuFourPage' +import { DogmaPage } from './Pages/about/DogmaPage' +import { GuidePage } from './Pages/about/GuidePage' +import { HelpPage } from './Pages/about/HelpPage' +import { ManifestPage } from './Pages/about/ManifestPage' +import { PartnersPage } from './Pages/about/PartnersPage' +import { ProjectsPage } from './Pages/about/ProjectsPage' +import { TermsOfUsePage } from './Pages/about/TermsOfUsePage' +import { ThanksPage } from './Pages/about/ThanksPage' -const HomePage = lazy(() => import('./Pages/HomePage')) -const AllTopicsPage = lazy(() => import('./Pages/AllTopicsPage')) -const TopicPage = lazy(() => import('./Pages/TopicPage')) -const AllAuthorsPage = lazy(() => import('./Pages/AllAuthorsPage')) -const AuthorPage = lazy(() => import('./Pages/AuthorPage')) -const FeedPage = lazy(() => import('./Pages/FeedPage')) -const ArticlePage = lazy(() => import('./Pages/ArticlePage')) -const SearchPage = lazy(() => import('./Pages/SearchPage')) -const FourOuFourPage = lazy(() => import('./Pages/FourOuFourPage')) -const DogmaPage = lazy(() => import('./Pages/about/DogmaPage')) - -const GuidePage = lazy(() => import('./Pages/about/GuidePage')) -const HelpPage = lazy(() => import('./Pages/about/HelpPage')) -const ManifestPage = lazy(() => import('./Pages/about/ManifestPage')) -const PartnersPage = lazy(() => import('./Pages/about/PartnersPage')) -const ProjectsPage = lazy(() => import('./Pages/about/ProjectsPage')) -const TermsOfUsePage = lazy(() => import('./Pages/about/TermsOfUsePage')) -const ThanksPage = lazy(() => import('./Pages/about/ThanksPage')) +// TODO: lazy load +// const HomePage = lazy(() => import('./Pages/HomePage')) +// const AllTopicsPage = lazy(() => import('./Pages/AllTopicsPage')) +// const TopicPage = lazy(() => import('./Pages/TopicPage')) +// const AllAuthorsPage = lazy(() => import('./Pages/AllAuthorsPage')) +// const AuthorPage = lazy(() => import('./Pages/AuthorPage')) +// const FeedPage = lazy(() => import('./Pages/FeedPage')) +// const ArticlePage = lazy(() => import('./Pages/ArticlePage')) +// const SearchPage = lazy(() => import('./Pages/SearchPage')) +// const FourOuFourPage = lazy(() => import('./Pages/FourOuFourPage')) +// const DogmaPage = lazy(() => import('./Pages/about/DogmaPage')) +// const GuidePage = lazy(() => import('./Pages/about/GuidePage')) +// const HelpPage = lazy(() => import('./Pages/about/HelpPage')) +// const ManifestPage = lazy(() => import('./Pages/about/ManifestPage')) +// const PartnersPage = lazy(() => import('./Pages/about/PartnersPage')) +// const ProjectsPage = lazy(() => import('./Pages/about/ProjectsPage')) +// const TermsOfUsePage = lazy(() => import('./Pages/about/TermsOfUsePage')) +// const ThanksPage = lazy(() => import('./Pages/about/ThanksPage')) const log = getLogger('root') diff --git a/src/components/Views/AllAuthors.tsx b/src/components/Views/AllAuthors.tsx index 38da7bf0..0cd3a79f 100644 --- a/src/components/Views/AllAuthors.tsx +++ b/src/components/Views/AllAuthors.tsx @@ -20,7 +20,7 @@ type Props = { } export const AllAuthorsView = (props: Props) => { - const { getSortedAuthors: authorslist } = useAuthorsStore({ authors: props.authors }) + const { sortedAuthors: authorList } = useAuthorsStore({ authors: props.authors }) const [sortedAuthors, setSortedAuthors] = createSignal([]) const [sortedKeys, setSortedKeys] = createSignal([]) const [abc, setAbc] = createSignal([]) @@ -32,7 +32,7 @@ export const AllAuthorsView = (props: Props) => { createEffect(() => { if ((!getSearchParams().by || getSearchParams().by === 'name') && abc().length === 0) { console.log('[authors] default grouping by abc') - const grouped = { ...groupByName(authorslist()) } + const grouped = { ...groupByName(authorList()) } grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar) setAbc(grouped) const keys = Object.keys(abc) @@ -40,13 +40,13 @@ export const AllAuthorsView = (props: Props) => { setSortedKeys(keys as string[]) } else { console.log('[authors] sorting by ' + getSearchParams().by) - setSortedAuthors(sortBy(authorslist(), getSearchParams().by)) + setSortedAuthors(sortBy(authorList(), getSearchParams().by)) } - }, [authorslist(), getSearchParams().by]) + }, [authorList(), getSearchParams().by]) return (
    - + 0}>
    diff --git a/src/components/Views/AllTopics.tsx b/src/components/Views/AllTopics.tsx index 786e1822..43b2b972 100644 --- a/src/components/Views/AllTopics.tsx +++ b/src/components/Views/AllTopics.tsx @@ -2,7 +2,7 @@ import { createEffect, For, Show } from 'solid-js' import type { Topic } from '../../graphql/types.gen' import { Icon } from '../Nav/Icon' import { t } from '../../utils/intl' -import { setSortAllTopicsBy, useTopicsStore } from '../../stores/zine/topics' +import { setSortAllBy as setSortAllTopicsBy, useTopicsStore } from '../../stores/zine/topics' import { handleClientRouteLinkClick, useRouter } from '../../stores/router' import { TopicCard } from '../Topic/Card' import { session } from '../../stores/auth' @@ -20,7 +20,7 @@ type Props = { export const AllTopicsView = (props: Props) => { const { getSearchParams, changeSearchParam } = useRouter() - const { getSortedTopics } = useTopicsStore({ + const { sortedTopics } = useTopicsStore({ topics: props.topics, sortBy: getSearchParams().by || 'shouts' }) @@ -34,7 +34,7 @@ export const AllTopicsView = (props: Props) => { return (
    - 0}> + 0}>
    @@ -78,7 +78,7 @@ export const AllTopicsView = (props: Props) => {
    - + {(topic) => ( )} diff --git a/src/components/Views/Author.tsx b/src/components/Views/Author.tsx index 32a0b7d0..16f43e3e 100644 --- a/src/components/Views/Author.tsx +++ b/src/components/Views/Author.tsx @@ -25,12 +25,12 @@ type AuthorPageSearchParams = { } export const AuthorView = (props: AuthorProps) => { - const { getSortedArticles: articles } = useArticlesStore({ + const { sortedArticles } = useArticlesStore({ sortedArticles: props.authorArticles }) - const { getAuthorEntities: authors } = useAuthorsStore({ authors: [props.author] }) + const { authorEntities } = useAuthorsStore({ authors: [props.author] }) - const author = createMemo(() => authors()[props.author.slug]) + const author = createMemo(() => authorEntities()[props.author.slug]) const { getSearchParams, changeSearchParam } = useRouter() //const slug = createMemo(() => author().slug) @@ -90,7 +90,7 @@ export const AuthorView = (props: AuthorProps) => {

    {title()}

    - 0}> + 0}> {/*FIXME*/} {/* { {/* wrapper={'topic'}*/} {/* topicShortDescription={true}*/} {/*/>*/} - - - - + + + +
    diff --git a/src/components/Views/Feed.tsx b/src/components/Views/Feed.tsx index bfa79ffb..24ad0308 100644 --- a/src/components/Views/Feed.tsx +++ b/src/components/Views/Feed.tsx @@ -31,11 +31,11 @@ interface FeedProps { export const FeedView = (props: FeedProps) => { // state - const { getSortedArticles: articles } = useArticlesStore({ sortedArticles: props.articles }) + const { sortedArticles } = useArticlesStore({ sortedArticles: props.articles }) const reactions = useReactionsStore() - const { getSortedAuthors: authors } = useAuthorsStore() - const { getTopTopics } = useTopicsStore() - const { getTopAuthors } = useTopAuthorsStore() + const { sortedAuthors } = useAuthorsStore() + const { topTopics } = useTopicsStore() + const { topAuthors } = useTopAuthorsStore() const auth = useStore(session) @@ -66,7 +66,7 @@ export const FeedView = (props: FeedProps) => {
    - +
    @@ -87,8 +87,8 @@ export const FeedView = (props: FeedProps) => { - 0}> - + 0}> + {(article) => } @@ -101,7 +101,7 @@ export const FeedView = (props: FeedProps) => {
      - + {(author) => (
    • @@ -110,7 +110,7 @@ export const FeedView = (props: FeedProps) => {
    - + {(article) => } @@ -127,10 +127,10 @@ export const FeedView = (props: FeedProps) => { {(comment) => } - 0}> + 0}>

    {t('Topics')}

    - + {(topic) => }
    diff --git a/src/components/Views/Home.tsx b/src/components/Views/Home.tsx index 61274cf8..fff7d4a9 100644 --- a/src/components/Views/Home.tsx +++ b/src/components/Views/Home.tsx @@ -36,44 +36,43 @@ const LOAD_MORE_ARTICLES_COUNT = 30 export const HomeView = (props: HomeProps) => { const { - getSortedArticles, - getTopArticles, - getTopMonthArticles, - getTopViewedArticles, - getTopCommentedArticles, - getArticlesByLayout + sortedArticles, + topArticles, + topMonthArticles, + topViewedArticles, + topCommentedArticles, + articlesByLayout } = useArticlesStore({ sortedArticles: props.recentPublishedArticles }) - const { getRandomTopics, getTopTopics } = useTopicsStore({ + const { randomTopics, topTopics } = useTopicsStore({ randomTopics: props.randomTopics }) - const { getTopAuthors } = useTopAuthorsStore() + const { topAuthors } = useTopAuthorsStore() onMount(() => { loadTopArticles() loadTopMonthArticles() - loadPublishedArticles({ limit: CLIENT_LOAD_ARTICLES_COUNT, offset: getSortedArticles().length }) + loadPublishedArticles({ limit: CLIENT_LOAD_ARTICLES_COUNT, offset: sortedArticles().length }) }) const randomLayout = createMemo(() => { - const articlesByLayout = getArticlesByLayout() - const filledLayouts = Object.keys(articlesByLayout).filter( + const filledLayouts = Object.keys(articlesByLayout()).filter( // FIXME: is 7 ok? or more complex logic needed? - (layout) => articlesByLayout[layout].length > 7 + (layout) => articlesByLayout()[layout].length > 7 ) - const randomLayout = + const selectedRandomLayout = filledLayouts.length > 0 ? filledLayouts[Math.floor(Math.random() * filledLayouts.length)] : '' return ( - + - +
    } /> @@ -82,68 +81,70 @@ export const HomeView = (props: HomeProps) => { }) const loadMore = () => { - loadPublishedArticles({ limit: LOAD_MORE_ARTICLES_COUNT, offset: getSortedArticles().length }) + loadPublishedArticles({ limit: LOAD_MORE_ARTICLES_COUNT, offset: sortedArticles().length }) } return ( - + - + - - - - - {/*FIXME: ?*/} - + 5}> + + + + {/*FIXME: ?*/} + + + + + + + + + + + + + {t('Top commented')}} /> + + {randomLayout()} + + + + + + + + + + + + + - - - - - - - - - {t('Top commented')}} /> - - {randomLayout()} - - - - - - - - - - - - - - - {(article) => } + {(article) => }