Merge branch 'minor-fixes-2' into 'dev'
Minor fixes See merge request discoursio/discoursio-webapp!63
This commit is contained in:
commit
20dde76aab
|
@ -105,7 +105,11 @@ export const Editor = (props: EditorProps) => {
|
||||||
Bold,
|
Bold,
|
||||||
Italic,
|
Italic,
|
||||||
Strike,
|
Strike,
|
||||||
HorizontalRule,
|
HorizontalRule.configure({
|
||||||
|
HTMLAttributes: {
|
||||||
|
class: 'horizontalRule'
|
||||||
|
}
|
||||||
|
}),
|
||||||
Underline,
|
Underline,
|
||||||
Link.configure({
|
Link.configure({
|
||||||
openOnClick: false
|
openOnClick: false
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { createMemo, For, Show } from 'solid-js'
|
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 { capitalize } from '../../utils'
|
||||||
import { translit } from '../../utils/ru2en'
|
import { translit } from '../../utils/ru2en'
|
||||||
import { Icon } from '../_shared/Icon'
|
import { Icon } from '../_shared/Icon'
|
||||||
|
@ -80,7 +80,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
const { changeSearchParam } = useRouter()
|
const { changeSearchParam } = useRouter()
|
||||||
const scrollToComments = (event) => {
|
const scrollToComments = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
openPage(router, 'article', { slug: slug })
|
openPage(router, 'article', { slug })
|
||||||
changeSearchParam('scrollTo', 'comments')
|
changeSearchParam('scrollTo', 'comments')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={!props.settings?.isGroup}>
|
<Show when={!props.settings?.isGroup && mainTopic}>
|
||||||
<CardTopic
|
<CardTopic
|
||||||
title={
|
title={
|
||||||
lang() === 'ru' && mainTopic.title ? mainTopic.title : mainTopic?.slug?.replace('-', ' ')
|
lang() === 'ru' && mainTopic.title ? mainTopic.title : mainTopic?.slug?.replace('-', ' ')
|
||||||
|
|
|
@ -212,13 +212,7 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Switch
|
<Switch>
|
||||||
fallback={
|
|
||||||
<div class="wide-container">
|
|
||||||
<p>{t('Nothing here yet')}</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Match when={searchParams().by === 'about'}>
|
<Match when={searchParams().by === 'about'}>
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<p>{author.bio}</p>
|
<p>{author.bio}</p>
|
||||||
|
|
|
@ -12,16 +12,7 @@ import { openPage } from '@nanostores/router'
|
||||||
import { translit } from '../../utils/ru2en'
|
import { translit } from '../../utils/ru2en'
|
||||||
import { Editor } from '../Editor/Editor'
|
import { Editor } from '../Editor/Editor'
|
||||||
import { Panel } from '../Editor/Panel'
|
import { Panel } from '../Editor/Panel'
|
||||||
|
import { useEditorContext } from '../../context/editor'
|
||||||
type ShoutForm = {
|
|
||||||
slug: string
|
|
||||||
title: string
|
|
||||||
subtitle: string
|
|
||||||
selectedTopics: Topic[]
|
|
||||||
mainTopic: string
|
|
||||||
body: string
|
|
||||||
coverImageUrl: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type EditViewProps = {
|
type EditViewProps = {
|
||||||
shout: Shout
|
shout: Shout
|
||||||
|
@ -33,9 +24,14 @@ export const EditView = (props: EditViewProps) => {
|
||||||
const [topics, setTopics] = createSignal<Topic[]>(null)
|
const [topics, setTopics] = createSignal<Topic[]>(null)
|
||||||
const { page } = useRouter()
|
const { page } = useRouter()
|
||||||
|
|
||||||
|
const {
|
||||||
|
form,
|
||||||
|
actions: { setForm }
|
||||||
|
} = useEditorContext()
|
||||||
|
|
||||||
const [isSlugChanged, setIsSlugChanged] = createSignal(false)
|
const [isSlugChanged, setIsSlugChanged] = createSignal(false)
|
||||||
|
|
||||||
const [form, setForm] = createStore<ShoutForm>({
|
setForm({
|
||||||
slug: props.shout.slug,
|
slug: props.shout.slug,
|
||||||
title: props.shout.title,
|
title: props.shout.title,
|
||||||
subtitle: props.shout.subtitle,
|
subtitle: props.shout.subtitle,
|
||||||
|
@ -77,24 +73,6 @@ export const EditView = (props: EditViewProps) => {
|
||||||
setForm('slug', slug)
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<div class={styles.container}>
|
<div class={styles.container}>
|
||||||
|
|
|
@ -1,17 +1,31 @@
|
||||||
import type { JSX } from 'solid-js'
|
import type { JSX } from 'solid-js'
|
||||||
import { Accessor, createContext, createSignal, useContext } 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 = {
|
type WordCounter = {
|
||||||
characters: number
|
characters: number
|
||||||
words: number
|
words: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ShoutForm = {
|
||||||
|
slug: string
|
||||||
|
title: string
|
||||||
|
subtitle: string
|
||||||
|
selectedTopics: Topic[]
|
||||||
|
mainTopic: string
|
||||||
|
body: string
|
||||||
|
coverImageUrl: string
|
||||||
|
}
|
||||||
|
|
||||||
type EditorContextType = {
|
type EditorContextType = {
|
||||||
isEditorPanelVisible: Accessor<boolean>
|
isEditorPanelVisible: Accessor<boolean>
|
||||||
wordCounter: Accessor<WordCounter>
|
wordCounter: Accessor<WordCounter>
|
||||||
|
form: ShoutForm
|
||||||
actions: {
|
actions: {
|
||||||
toggleEditorPanel: () => void
|
toggleEditorPanel: () => void
|
||||||
countWords: (value: WordCounter) => void
|
countWords: (value: WordCounter) => void
|
||||||
|
setForm: SetStoreFunction<ShoutForm>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +37,9 @@ export function useEditorContext() {
|
||||||
|
|
||||||
export const EditorProvider = (props: { children: JSX.Element }) => {
|
export const EditorProvider = (props: { children: JSX.Element }) => {
|
||||||
const [isEditorPanelVisible, setIsEditorPanelVisible] = createSignal<boolean>(false)
|
const [isEditorPanelVisible, setIsEditorPanelVisible] = createSignal<boolean>(false)
|
||||||
|
|
||||||
|
const [form, setForm] = createStore<ShoutForm>(null)
|
||||||
|
|
||||||
const [wordCounter, setWordCounter] = createSignal<WordCounter>({
|
const [wordCounter, setWordCounter] = createSignal<WordCounter>({
|
||||||
characters: 0,
|
characters: 0,
|
||||||
words: 0
|
words: 0
|
||||||
|
@ -31,10 +48,11 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
|
||||||
const countWords = (value) => setWordCounter(value)
|
const countWords = (value) => setWordCounter(value)
|
||||||
const actions = {
|
const actions = {
|
||||||
toggleEditorPanel,
|
toggleEditorPanel,
|
||||||
countWords
|
countWords,
|
||||||
|
setForm
|
||||||
}
|
}
|
||||||
|
|
||||||
const value: EditorContextType = { actions, isEditorPanelVisible, wordCounter }
|
const value: EditorContextType = { actions, form, isEditorPanelVisible, wordCounter }
|
||||||
|
|
||||||
return <EditorContext.Provider value={value}>{props.children}</EditorContext.Provider>
|
return <EditorContext.Provider value={value}>{props.children}</EditorContext.Provider>
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type { Accessor, JSX } from 'solid-js'
|
||||||
import { createContext, createSignal, useContext } from 'solid-js'
|
import { createContext, createSignal, useContext } from 'solid-js'
|
||||||
import { delay } from '../utils/delay'
|
import { delay } from '../utils/delay'
|
||||||
|
|
||||||
const DEFAULT_DURATION = 5000 // 5 sec
|
const DEFAULT_DURATION = 3000 // 3 sec
|
||||||
|
|
||||||
type SnackbarMessage = {
|
type SnackbarMessage = {
|
||||||
type: 'success' | 'error'
|
type: 'success' | 'error'
|
||||||
|
|
|
@ -5,7 +5,7 @@ export default gql`
|
||||||
createShout(inp: $shout) {
|
createShout(inp: $shout) {
|
||||||
error
|
error
|
||||||
shout {
|
shout {
|
||||||
_id: slug
|
id
|
||||||
slug
|
slug
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default gql`
|
||||||
error
|
error
|
||||||
token
|
token
|
||||||
user {
|
user {
|
||||||
_id: slug
|
id
|
||||||
email
|
email
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
mutation CommunityUpdateMutation($community: Community!) {
|
mutation CommunityUpdateMutation($community: Community!) {
|
||||||
updateCommunity(community: $community) {
|
updateCommunity(community: $community) {
|
||||||
_id: slug
|
id
|
||||||
slug
|
slug
|
||||||
desc
|
desc
|
||||||
name
|
name
|
||||||
|
|
|
@ -6,7 +6,6 @@ export default gql`
|
||||||
error
|
error
|
||||||
token
|
token
|
||||||
user {
|
user {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
|
|
|
@ -17,7 +17,6 @@ export default gql`
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query LoadShoutsQuery($options: LoadShoutsOptions) {
|
query LoadShoutsQuery($options: LoadShoutsOptions) {
|
||||||
loadShouts(options: $options) {
|
loadShouts(options: $options) {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
|
@ -18,7 +17,6 @@ export default gql`
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
@ -33,7 +31,6 @@ export default gql`
|
||||||
createdAt
|
createdAt
|
||||||
publishedAt
|
publishedAt
|
||||||
stat {
|
stat {
|
||||||
_id: viewed
|
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
||||||
rating
|
rating
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query GetAuthorBySlugQuery($slug: String!) {
|
query GetAuthorBySlugQuery($slug: String!) {
|
||||||
getAuthor(slug: $slug) {
|
getAuthor(slug: $slug) {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
@ -15,7 +14,6 @@ export default gql`
|
||||||
createdAt
|
createdAt
|
||||||
lastSeen
|
lastSeen
|
||||||
# ratings {
|
# ratings {
|
||||||
# _id: rater
|
|
||||||
# rater
|
# rater
|
||||||
# value
|
# value
|
||||||
# }
|
# }
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query UserSubscribersQuery($slug: String!) {
|
query UserSubscribersQuery($slug: String!) {
|
||||||
userFollowers(slug: $slug) {
|
userFollowers(slug: $slug) {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query ShoutsReactedByUserQuery($slug: String!, $limit: Int!, $offset: Int!) {
|
query ShoutsReactedByUserQuery($slug: String!, $limit: Int!, $offset: Int!) {
|
||||||
userReactedShouts(slug: String!, page: Int!, size: Int!) {
|
userReactedShouts(slug: String!, page: Int!, size: Int!) {
|
||||||
_id: slug
|
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
layout
|
layout
|
||||||
|
@ -19,7 +18,6 @@ export default gql`
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
@ -34,7 +32,6 @@ export default gql`
|
||||||
createdAt
|
createdAt
|
||||||
publishedAt
|
publishedAt
|
||||||
stat {
|
stat {
|
||||||
_id: viewed
|
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
||||||
rating
|
rating
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query AuthorsAllQuery {
|
query AuthorsAllQuery {
|
||||||
authorsAll {
|
authorsAll {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) {
|
query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) {
|
||||||
loadAuthorsBy(by: $by, limit: $limit, offset: $offset) {
|
loadAuthorsBy(by: $by, limit: $limit, offset: $offset) {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
@ -14,7 +13,6 @@ export default gql`
|
||||||
# createdAt
|
# createdAt
|
||||||
lastSeen
|
lastSeen
|
||||||
# ratings {
|
# ratings {
|
||||||
# _id: rater
|
|
||||||
# rater
|
# rater
|
||||||
# value
|
# value
|
||||||
# }
|
# }
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query MyFeedQuery($options: LoadShoutsOptions) {
|
query MyFeedQuery($options: LoadShoutsOptions) {
|
||||||
myFeed(options: $options) {
|
myFeed(options: $options) {
|
||||||
_id: slug
|
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
|
@ -18,7 +17,6 @@ export default gql`
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
@ -33,7 +31,6 @@ export default gql`
|
||||||
createdAt
|
createdAt
|
||||||
publishedAt
|
publishedAt
|
||||||
stat {
|
stat {
|
||||||
_id: viewed
|
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
||||||
rating
|
rating
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
||||||
pic
|
pic
|
||||||
# community
|
# community
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
# viewed
|
# viewed
|
||||||
|
|
|
@ -3,14 +3,12 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query TopicsAllQuery {
|
query TopicsAllQuery {
|
||||||
topicsAll {
|
topicsAll {
|
||||||
_id: slug
|
|
||||||
title
|
title
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
pic
|
pic
|
||||||
# community
|
# community
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
||||||
pic
|
pic
|
||||||
# community
|
# community
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
||||||
pic
|
pic
|
||||||
# community
|
# community
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
|
|
@ -3,14 +3,13 @@ import { gql } from '@urql/core'
|
||||||
export default gql`
|
export default gql`
|
||||||
query TopicsRandomQuery($amount: Int) {
|
query TopicsRandomQuery($amount: Int) {
|
||||||
topicsRandom(amount: $amount) {
|
topicsRandom(amount: $amount) {
|
||||||
_id: slug
|
id
|
||||||
title
|
title
|
||||||
body
|
body
|
||||||
slug
|
slug
|
||||||
pic
|
pic
|
||||||
# community
|
# community
|
||||||
stat {
|
stat {
|
||||||
_id: shouts
|
|
||||||
shouts
|
shouts
|
||||||
authors
|
authors
|
||||||
followers
|
followers
|
||||||
|
|
|
@ -28,7 +28,10 @@ export const AuthorPage = (props: PageProps) => {
|
||||||
return
|
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() })
|
await loadAuthor({ slug: slug() })
|
||||||
|
|
||||||
setIsLoaded(true)
|
setIsLoaded(true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user