diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index 7663c803..80f46321 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -105,7 +105,11 @@ export const Editor = (props: EditorProps) => { Bold, Italic, Strike, - HorizontalRule, + HorizontalRule.configure({ + HTMLAttributes: { + class: 'horizontalRule' + } + }), Underline, Link.configure({ openOnClick: false diff --git a/src/components/Feed/ArticleCard.tsx b/src/components/Feed/ArticleCard.tsx index b05535f3..ce902e03 100644 --- a/src/components/Feed/ArticleCard.tsx +++ b/src/components/Feed/ArticleCard.tsx @@ -1,5 +1,5 @@ import { createMemo, For, Show } from 'solid-js' -import type { Shout } from '../../graphql/types.gen' +import type { Shout, Topic } from '../../graphql/types.gen' import { capitalize } from '../../utils' import { translit } from '../../utils/ru2en' import { Icon } from '../_shared/Icon' @@ -80,7 +80,7 @@ export const ArticleCard = (props: ArticleCardProps) => { const { changeSearchParam } = useRouter() const scrollToComments = (event) => { event.preventDefault() - openPage(router, 'article', { slug: slug }) + openPage(router, 'article', { slug }) changeSearchParam('scrollTo', 'comments') } @@ -118,7 +118,7 @@ export const ArticleCard = (props: ArticleCardProps) => { - + { - -

{t('Nothing here yet')}

- - } - > +

{author.bio}

diff --git a/src/components/Views/Edit.tsx b/src/components/Views/Edit.tsx index bc0fb617..d871fda0 100644 --- a/src/components/Views/Edit.tsx +++ b/src/components/Views/Edit.tsx @@ -12,16 +12,7 @@ import { openPage } from '@nanostores/router' import { translit } from '../../utils/ru2en' import { Editor } from '../Editor/Editor' import { Panel } from '../Editor/Panel' - -type ShoutForm = { - slug: string - title: string - subtitle: string - selectedTopics: Topic[] - mainTopic: string - body: string - coverImageUrl: string -} +import { useEditorContext } from '../../context/editor' type EditViewProps = { shout: Shout @@ -33,9 +24,14 @@ export const EditView = (props: EditViewProps) => { const [topics, setTopics] = createSignal(null) const { page } = useRouter() + const { + form, + actions: { setForm } + } = useEditorContext() + const [isSlugChanged, setIsSlugChanged] = createSignal(false) - const [form, setForm] = createStore({ + setForm({ slug: props.shout.slug, title: props.shout.title, subtitle: props.shout.subtitle, @@ -77,24 +73,6 @@ export const EditView = (props: EditViewProps) => { setForm('slug', slug) } - const handleSaveButtonClick = async (e) => { - e.preventDefault() - - await apiClient.updateArticle({ - slug: props.shout.slug, - article: { - slug: form.slug, - title: form.title, - subtitle: form.subtitle, - body: form.body, - topics: form.selectedTopics.map((topic) => topic.slug), - mainTopic: form.selectedTopics[0].slug - } - }) - - openPage(router, 'drafts') - } - return ( <>
diff --git a/src/context/editor.tsx b/src/context/editor.tsx index 5d8fe5dc..9b3072ff 100644 --- a/src/context/editor.tsx +++ b/src/context/editor.tsx @@ -1,17 +1,31 @@ import type { JSX } from 'solid-js' import { Accessor, createContext, createSignal, useContext } from 'solid-js' +import { createStore, SetStoreFunction } from 'solid-js/store' +import { Topic } from '../graphql/types.gen' type WordCounter = { characters: number words: number } +type ShoutForm = { + slug: string + title: string + subtitle: string + selectedTopics: Topic[] + mainTopic: string + body: string + coverImageUrl: string +} + type EditorContextType = { isEditorPanelVisible: Accessor wordCounter: Accessor + form: ShoutForm actions: { toggleEditorPanel: () => void countWords: (value: WordCounter) => void + setForm: SetStoreFunction } } @@ -23,6 +37,9 @@ export function useEditorContext() { export const EditorProvider = (props: { children: JSX.Element }) => { const [isEditorPanelVisible, setIsEditorPanelVisible] = createSignal(false) + + const [form, setForm] = createStore(null) + const [wordCounter, setWordCounter] = createSignal({ characters: 0, words: 0 @@ -31,10 +48,11 @@ export const EditorProvider = (props: { children: JSX.Element }) => { const countWords = (value) => setWordCounter(value) const actions = { toggleEditorPanel, - countWords + countWords, + setForm } - const value: EditorContextType = { actions, isEditorPanelVisible, wordCounter } + const value: EditorContextType = { actions, form, isEditorPanelVisible, wordCounter } return {props.children} } diff --git a/src/context/snackbar.tsx b/src/context/snackbar.tsx index bb7362a4..57d7de24 100644 --- a/src/context/snackbar.tsx +++ b/src/context/snackbar.tsx @@ -2,7 +2,7 @@ import type { Accessor, JSX } from 'solid-js' import { createContext, createSignal, useContext } from 'solid-js' import { delay } from '../utils/delay' -const DEFAULT_DURATION = 5000 // 5 sec +const DEFAULT_DURATION = 3000 // 3 sec type SnackbarMessage = { type: 'success' | 'error' diff --git a/src/graphql/mutation/article-create.ts b/src/graphql/mutation/article-create.ts index cbc7a890..f38b3240 100644 --- a/src/graphql/mutation/article-create.ts +++ b/src/graphql/mutation/article-create.ts @@ -5,7 +5,7 @@ export default gql` createShout(inp: $shout) { error shout { - _id: slug + id slug title subtitle diff --git a/src/graphql/mutation/auth-confirm-email.ts b/src/graphql/mutation/auth-confirm-email.ts index 0de4a5c7..f2286e3d 100644 --- a/src/graphql/mutation/auth-confirm-email.ts +++ b/src/graphql/mutation/auth-confirm-email.ts @@ -6,7 +6,7 @@ export default gql` error token user { - _id: slug + id email name slug diff --git a/src/graphql/mutation/community-update.ts b/src/graphql/mutation/community-update.ts index 8621613c..a7783faf 100644 --- a/src/graphql/mutation/community-update.ts +++ b/src/graphql/mutation/community-update.ts @@ -3,7 +3,7 @@ import { gql } from '@urql/core' export default gql` mutation CommunityUpdateMutation($community: Community!) { updateCommunity(community: $community) { - _id: slug + id slug desc name diff --git a/src/graphql/mutation/my-session.ts b/src/graphql/mutation/my-session.ts index 0102b07b..d2972be3 100644 --- a/src/graphql/mutation/my-session.ts +++ b/src/graphql/mutation/my-session.ts @@ -6,7 +6,6 @@ export default gql` error token user { - _id: slug id name slug diff --git a/src/graphql/query/article-drafts-load-by.ts b/src/graphql/query/article-drafts-load-by.ts index 6fd57bfc..59610321 100644 --- a/src/graphql/query/article-drafts-load-by.ts +++ b/src/graphql/query/article-drafts-load-by.ts @@ -17,7 +17,6 @@ export default gql` body slug stat { - _id: shouts shouts authors followers diff --git a/src/graphql/query/articles-load-by.ts b/src/graphql/query/articles-load-by.ts index b7929c2c..f7c7b541 100644 --- a/src/graphql/query/articles-load-by.ts +++ b/src/graphql/query/articles-load-by.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query LoadShoutsQuery($options: LoadShoutsOptions) { loadShouts(options: $options) { - _id: slug id title subtitle @@ -18,7 +17,6 @@ export default gql` body slug stat { - _id: shouts shouts authors followers @@ -33,7 +31,6 @@ export default gql` createdAt publishedAt stat { - _id: viewed viewed reacted rating diff --git a/src/graphql/query/author-by-slug.ts b/src/graphql/query/author-by-slug.ts index f27a0068..b6537e9d 100644 --- a/src/graphql/query/author-by-slug.ts +++ b/src/graphql/query/author-by-slug.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query GetAuthorBySlugQuery($slug: String!) { getAuthor(slug: $slug) { - _id: slug id slug name @@ -15,7 +14,6 @@ export default gql` createdAt lastSeen # ratings { - # _id: rater # rater # value # } diff --git a/src/graphql/query/author-followers.ts b/src/graphql/query/author-followers.ts index 882c5af0..13cf82b0 100644 --- a/src/graphql/query/author-followers.ts +++ b/src/graphql/query/author-followers.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query UserSubscribersQuery($slug: String!) { userFollowers(slug: $slug) { - _id: slug id slug name diff --git a/src/graphql/query/author-reacted-shouts.ts b/src/graphql/query/author-reacted-shouts.ts index 825375d3..780e9c3a 100644 --- a/src/graphql/query/author-reacted-shouts.ts +++ b/src/graphql/query/author-reacted-shouts.ts @@ -5,7 +5,6 @@ import { gql } from '@urql/core' export default gql` query ShoutsReactedByUserQuery($slug: String!, $limit: Int!, $offset: Int!) { userReactedShouts(slug: String!, page: Int!, size: Int!) { - _id: slug title subtitle layout @@ -19,7 +18,6 @@ export default gql` body slug stat { - _id: shouts shouts authors followers @@ -34,7 +32,6 @@ export default gql` createdAt publishedAt stat { - _id: viewed viewed reacted rating diff --git a/src/graphql/query/authors-all.ts b/src/graphql/query/authors-all.ts index b5a6e65a..06e9ad75 100644 --- a/src/graphql/query/authors-all.ts +++ b/src/graphql/query/authors-all.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query AuthorsAllQuery { authorsAll { - _id: slug id slug name diff --git a/src/graphql/query/authors-load-by.ts b/src/graphql/query/authors-load-by.ts index fdafd924..97cd436d 100644 --- a/src/graphql/query/authors-load-by.ts +++ b/src/graphql/query/authors-load-by.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) { loadAuthorsBy(by: $by, limit: $limit, offset: $offset) { - _id: slug id slug name @@ -14,7 +13,6 @@ export default gql` # createdAt lastSeen # ratings { - # _id: rater # rater # value # } diff --git a/src/graphql/query/my-feed.ts b/src/graphql/query/my-feed.ts index dee34894..42463b92 100644 --- a/src/graphql/query/my-feed.ts +++ b/src/graphql/query/my-feed.ts @@ -3,7 +3,6 @@ import { gql } from '@urql/core' export default gql` query MyFeedQuery($options: LoadShoutsOptions) { myFeed(options: $options) { - _id: slug id title subtitle @@ -18,7 +17,6 @@ export default gql` body slug stat { - _id: shouts shouts authors followers @@ -33,7 +31,6 @@ export default gql` createdAt publishedAt stat { - _id: viewed viewed reacted rating diff --git a/src/graphql/query/topic-by-slug.ts b/src/graphql/query/topic-by-slug.ts index 7ed25aa2..7b01a05e 100644 --- a/src/graphql/query/topic-by-slug.ts +++ b/src/graphql/query/topic-by-slug.ts @@ -9,7 +9,6 @@ export default gql` pic # community stat { - _id: shouts shouts authors # viewed diff --git a/src/graphql/query/topics-all.ts b/src/graphql/query/topics-all.ts index e20575f2..d2ab1263 100644 --- a/src/graphql/query/topics-all.ts +++ b/src/graphql/query/topics-all.ts @@ -3,14 +3,12 @@ import { gql } from '@urql/core' export default gql` query TopicsAllQuery { topicsAll { - _id: slug title body slug pic # community stat { - _id: shouts shouts authors followers diff --git a/src/graphql/query/topics-by-author.ts b/src/graphql/query/topics-by-author.ts index eaae45bc..cb842d2a 100644 --- a/src/graphql/query/topics-by-author.ts +++ b/src/graphql/query/topics-by-author.ts @@ -9,7 +9,6 @@ export default gql` pic # community stat { - _id: shouts shouts authors followers diff --git a/src/graphql/query/topics-by-community.ts b/src/graphql/query/topics-by-community.ts index 32213a51..4060aacd 100644 --- a/src/graphql/query/topics-by-community.ts +++ b/src/graphql/query/topics-by-community.ts @@ -9,7 +9,6 @@ export default gql` pic # community stat { - _id: shouts shouts authors followers diff --git a/src/graphql/query/topics-random.ts b/src/graphql/query/topics-random.ts index c84b4360..43deecc4 100644 --- a/src/graphql/query/topics-random.ts +++ b/src/graphql/query/topics-random.ts @@ -3,14 +3,13 @@ import { gql } from '@urql/core' export default gql` query TopicsRandomQuery($amount: Int) { topicsRandom(amount: $amount) { - _id: slug + id title body slug pic # community stat { - _id: shouts shouts authors followers diff --git a/src/pages/author.page.tsx b/src/pages/author.page.tsx index 248cbb51..2a67d931 100644 --- a/src/pages/author.page.tsx +++ b/src/pages/author.page.tsx @@ -28,7 +28,10 @@ export const AuthorPage = (props: PageProps) => { return } - await loadShouts({ filters: { author: slug() }, limit: PRERENDERED_ARTICLES_COUNT }) + await loadShouts({ + filters: { author: slug(), visibility: 'community' }, + limit: PRERENDERED_ARTICLES_COUNT + }) await loadAuthor({ slug: slug() }) setIsLoaded(true)