From c3c1c9fee36a2ef43be9c799d91da286815912af Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Tue, 13 Sep 2022 11:59:04 +0200 Subject: [PATCH 1/2] store layer --- .eslintignore | 2 + .stylelintignore | 2 + src/components/Article/Comment.tsx | 13 +- src/components/Article/FullArticle.tsx | 70 +++++---- src/components/Author/Card.tsx | 1 - src/components/Editor/Sidebar.tsx | 92 +++++------ src/components/Feed/Sidebar.tsx | 70 +++++---- src/components/Nav/AuthModal.tsx | 2 +- src/components/Topic/Card.tsx | 53 ++++--- src/components/Views/ArticlePage.tsx | 2 +- src/components/Views/Author.tsx | 30 ++-- src/components/Views/Create.tsx | 2 +- src/components/Views/Feed.tsx | 88 +++++------ src/components/Views/Home.tsx | 155 ++++++++++--------- src/components/Views/Search.tsx | 49 ++---- src/components/Views/Topic.tsx | 43 +++--- src/graphql/mutation/my-session.ts | 2 +- src/pages/[...slug].astro | 18 +-- src/pages/feed/index.astro | 4 +- src/pages/index.astro | 4 +- src/pages/search.astro | 4 +- src/stores/auth.ts | 44 +++--- src/stores/zine/articles.ts | 206 ++++++++++++++++++------- src/stores/zine/authors.ts | 56 +++++-- src/stores/zine/currentArticle.ts | 13 +- src/stores/zine/reactions.ts | 30 ++-- src/stores/zine/seen.ts | 16 +- src/stores/zine/top.ts | 49 ------ src/stores/zine/topics.ts | 59 ++++++- src/utils/apiClient.ts | 79 ++++++---- src/utils/sortby.ts | 4 +- 31 files changed, 709 insertions(+), 553 deletions(-) create mode 100644 .stylelintignore delete mode 100644 src/stores/zine/top.ts diff --git a/.eslintignore b/.eslintignore index b896d136..37584469 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,5 @@ public *.cjs src/graphql/*.gen.ts src/legacy_* +dist/ +.vercel/ diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 00000000..fd2fbae2 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,2 @@ +.vercel/ +dist/ diff --git a/src/components/Article/Comment.tsx b/src/components/Article/Comment.tsx index a5e83d5c..6ebfe41c 100644 --- a/src/components/Article/Comment.tsx +++ b/src/components/Article/Comment.tsx @@ -9,6 +9,7 @@ import { t } from '../../utils/intl' // import { createReaction, updateReaction, deleteReaction } from '../../stores/zine/reactions' import { renderMarkdown } from '@astrojs/markdown-remark' import { markdownOptions } from '../../../mdx.config' +import { deleteReaction } from '../../stores/zine/reactions' export default (props: { level?: number @@ -20,16 +21,16 @@ export default (props: { const [body, setBody] = createSignal('') onMount(() => { const b: string = props.comment?.body - if (b?.toString().startsWith('<')) setBody(b) - else { + if (b?.toString().startsWith('<')) { + setBody(b) + } else { renderMarkdown(b, markdownOptions).then(({ code }) => setBody(code)) } }) const remove = () => { if (comment()?.id) { console.log('[comment] removing', comment().id) - // FIXME - // deleteReaction(comment().id) + deleteReaction(comment().id) } } @@ -79,7 +80,7 @@ export default (props: { - {/*FIXME*/} + {/*FIXME implement edit comment modal*/} {/* showModal('editComment')}*/} @@ -93,7 +94,7 @@ export default (props: { - {/*FIXME*/} + {/*FIXME implement modals */} {/* showModal('shareComment')}*/} diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index 5f3a3233..b49b6a2e 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -9,6 +9,9 @@ import { t } from '../../utils/intl' import { showModal } from '../../stores/ui' import { renderMarkdown } from '@astrojs/markdown-remark' import { markdownOptions } from '../../../mdx.config' +import { useStore } from '@nanostores/solid' +import { session } from '../../stores/auth' + const MAX_COMMENT_LEVEL = 6 const getCommentLevel = (comment: Reaction, level = 0) => { @@ -36,10 +39,14 @@ const formatDate = (date: Date) => { export const FullArticle = (props: ArticleProps) => { const [body, setBody] = createSignal('') + + const auth = useStore(session) + onMount(() => { const b: string = props.article?.body - if (b?.toString().startsWith('<')) setBody(b) - else { + if (b?.toString().startsWith('<')) { + setBody(b) + } else { renderMarkdown(b, markdownOptions).then(({ code }) => setBody(code)) } }) @@ -136,16 +143,15 @@ export const FullArticle = (props: ArticleProps) => {
{formattedDate}
- {/*FIXME*/} - {/*
*/} - {/* */} - {/* {(topic) => (*/} - {/* */} - {/* )}*/} - {/* */} - {/*
*/} +
+ + {(topic) => ( + + )} + +
1}> @@ -166,32 +172,28 @@ export const FullArticle = (props: ArticleProps) => { )} - - {/*FIXME*/} - {/**/} - {/*
*/} - {/* {t('To leave a comment you please')}*/} - {/* {*/} - {/* evt.preventDefault()*/} - {/* showModal('auth')*/} - {/* }}*/} - {/* >*/} - {/* {t('sign up or sign in')}*/} - {/* */} - {/*
*/} - {/*
*/} - {/**/} - {/*