Merge remote-tracking branch 'gitlab/dev' into drafts
# Conflicts: # src/components/Editor/Editor.tsx # src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.module.scss # src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx # src/components/Editor/EditorFloatingMenu/Menu/Menu.tsx # src/components/Editor/UploadModal/UploadModalContent.tsx
This commit is contained in:
parent
378fc65955
commit
c4ec7d0a7e
|
@ -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) => {
|
|||
</div>
|
||||
</Show>
|
||||
|
||||
<Show when={!props.settings?.isGroup}>
|
||||
<Show when={!props.settings?.isGroup && mainTopic}>
|
||||
<CardTopic
|
||||
title={
|
||||
lang() === 'ru' && mainTopic.title ? mainTopic.title : mainTopic?.slug?.replace('-', ' ')
|
||||
|
|
|
@ -212,13 +212,7 @@ export const AuthorView = (props: AuthorProps) => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<Switch
|
||||
fallback={
|
||||
<div class="wide-container">
|
||||
<p>{t('Nothing here yet')}</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<Switch>
|
||||
<Match when={searchParams().by === 'about'}>
|
||||
<div class="wide-container">
|
||||
<p>{author.bio}</p>
|
||||
|
|
|
@ -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<Topic[]>(null)
|
||||
const { page } = useRouter()
|
||||
|
||||
const {
|
||||
form,
|
||||
actions: { setForm }
|
||||
} = useEditorContext()
|
||||
|
||||
const [isSlugChanged, setIsSlugChanged] = createSignal(false)
|
||||
|
||||
const [form, setForm] = createStore<ShoutForm>({
|
||||
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 (
|
||||
<>
|
||||
<div class={styles.container}>
|
||||
|
|
|
@ -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<boolean>
|
||||
wordCounter: Accessor<WordCounter>
|
||||
form: ShoutForm
|
||||
actions: {
|
||||
toggleEditorPanel: () => void
|
||||
countWords: (value: WordCounter) => void
|
||||
setForm: SetStoreFunction<ShoutForm>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +37,9 @@ export function useEditorContext() {
|
|||
|
||||
export const EditorProvider = (props: { children: JSX.Element }) => {
|
||||
const [isEditorPanelVisible, setIsEditorPanelVisible] = createSignal<boolean>(false)
|
||||
|
||||
const [form, setForm] = createStore<ShoutForm>(null)
|
||||
|
||||
const [wordCounter, setWordCounter] = createSignal<WordCounter>({
|
||||
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 <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 { delay } from '../utils/delay'
|
||||
|
||||
const DEFAULT_DURATION = 5000 // 5 sec
|
||||
const DEFAULT_DURATION = 3000 // 3 sec
|
||||
|
||||
type SnackbarMessage = {
|
||||
type: 'success' | 'error'
|
||||
|
|
|
@ -5,7 +5,7 @@ export default gql`
|
|||
createShout(inp: $shout) {
|
||||
error
|
||||
shout {
|
||||
_id: slug
|
||||
id
|
||||
slug
|
||||
title
|
||||
subtitle
|
||||
|
|
|
@ -6,7 +6,7 @@ export default gql`
|
|||
error
|
||||
token
|
||||
user {
|
||||
_id: slug
|
||||
id
|
||||
email
|
||||
name
|
||||
slug
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,7 +6,6 @@ export default gql`
|
|||
error
|
||||
token
|
||||
user {
|
||||
_id: slug
|
||||
id
|
||||
name
|
||||
slug
|
||||
|
|
|
@ -17,7 +17,6 @@ export default gql`
|
|||
body
|
||||
slug
|
||||
stat {
|
||||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
followers
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
# }
|
||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
|||
export default gql`
|
||||
query UserSubscribersQuery($slug: String!) {
|
||||
userFollowers(slug: $slug) {
|
||||
_id: slug
|
||||
id
|
||||
slug
|
||||
name
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,7 +3,6 @@ import { gql } from '@urql/core'
|
|||
export default gql`
|
||||
query AuthorsAllQuery {
|
||||
authorsAll {
|
||||
_id: slug
|
||||
id
|
||||
slug
|
||||
name
|
||||
|
|
|
@ -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
|
||||
# }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
|||
pic
|
||||
# community
|
||||
stat {
|
||||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
# viewed
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
|||
pic
|
||||
# community
|
||||
stat {
|
||||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
followers
|
||||
|
|
|
@ -9,7 +9,6 @@ export default gql`
|
|||
pic
|
||||
# community
|
||||
stat {
|
||||
_id: shouts
|
||||
shouts
|
||||
authors
|
||||
followers
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user