Merge pull request #376 from Discours/fix/topic_select

Fix TopicSelect
This commit is contained in:
Tony 2024-01-23 22:06:22 +03:00 committed by GitHub
commit 3a3d4e87ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -56,7 +56,7 @@ export const TopicSelect = (props: TopicSelectProps) => {
return item.label return item.label
} }
const isMainTopic = item.id === props.mainTopic.id const isMainTopic = item.id === props.mainTopic?.id
return ( return (
<div <div

View File

@ -1,11 +1,12 @@
import { redirectPage } from '@nanostores/router' import { redirectPage } from '@nanostores/router'
import { clsx } from 'clsx' import { clsx } from 'clsx'
import { createEffect, lazy, Show } from 'solid-js' import { createEffect, createSignal, lazy, Show } from 'solid-js'
import { createStore } from 'solid-js/store' import { createStore } from 'solid-js/store'
import { ShoutForm, useEditorContext } from '../../../context/editor' import { ShoutForm, useEditorContext } from '../../../context/editor'
import { useLocalize } from '../../../context/localize' import { useLocalize } from '../../../context/localize'
import { useSession } from '../../../context/session' import { useSession } from '../../../context/session'
import { Topic } from '../../../graphql/schema/core.gen'
import { UploadedFile } from '../../../pages/types' import { UploadedFile } from '../../../pages/types'
import { router } from '../../../stores/router' import { router } from '../../../stores/router'
import { hideModal, showModal } from '../../../stores/ui' import { hideModal, showModal } from '../../../stores/ui'
@ -40,10 +41,11 @@ export const PublishSettings = (props: Props) => {
const { author } = useSession() const { author } = useSession()
const { sortedTopics } = useTopicsStore() const { sortedTopics } = useTopicsStore()
const [topics, setTopics] = createSignal<Topic[]>(sortedTopics())
createEffect(async () => { createEffect(async () => {
if (sortedTopics()?.length < 33) { await loadAllTopics()
await loadAllTopics() setTopics(sortedTopics())
}
}) })
const composeDescription = () => { const composeDescription = () => {
@ -212,9 +214,9 @@ export const PublishSettings = (props: Props) => {
</p> </p>
<div class={styles.inputContainer}> <div class={styles.inputContainer}>
<div class={clsx('pretty-form__item', styles.topicSelectContainer)}> <div class={clsx('pretty-form__item', styles.topicSelectContainer)}>
<Show when={sortedTopics()}> <Show when={topics().length > 0}>
<TopicSelect <TopicSelect
topics={sortedTopics()} topics={topics()}
onChange={handleTopicSelectChange} onChange={handleTopicSelectChange}
selectedTopics={props.form.selectedTopics} selectedTopics={props.form.selectedTopics}
onMainTopicChange={(mainTopic) => setForm('mainTopic', mainTopic)} onMainTopicChange={(mainTopic) => setForm('mainTopic', mainTopic)}