profile-debug
This commit is contained in:
parent
0f02d4bdc2
commit
2bbaaa6cf1
|
@ -9,7 +9,7 @@ import { useLocalize } from '../../../context/localize'
|
|||
import { apiClient } from '../../../graphql/client/core'
|
||||
import { router, useRouter } from '../../../stores/router'
|
||||
import { loadShouts, useArticlesStore } from '../../../stores/zine/articles'
|
||||
import { useAuthorsStore } from '../../../stores/zine/authors'
|
||||
import { loadAuthor, useAuthorsStore } from '../../../stores/zine/authors'
|
||||
import { getImageUrl } from '../../../utils/getImageUrl'
|
||||
import { getDescription } from '../../../utils/meta'
|
||||
import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll'
|
||||
|
@ -24,6 +24,7 @@ import { Row3 } from '../../Feed/Row3'
|
|||
|
||||
import styles from './Author.module.scss'
|
||||
import stylesArticle from '../../Article/Article.module.scss'
|
||||
import { useSession } from '../../../context/session'
|
||||
|
||||
type Props = {
|
||||
shouts: Shout[]
|
||||
|
@ -38,18 +39,21 @@ export const AuthorView = (props: Props) => {
|
|||
const { t } = useLocalize()
|
||||
const { sortedArticles } = useArticlesStore({ shouts: props.shouts })
|
||||
const { authorEntities } = useAuthorsStore({ authors: [props.author] })
|
||||
|
||||
const { page: getPage } = useRouter()
|
||||
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
|
||||
const [isBioExpanded, setIsBioExpanded] = createSignal(false)
|
||||
const [followers, setFollowers] = createSignal<Author[]>([])
|
||||
const [following, setFollowing] = createSignal<Array<Author | Topic>>([])
|
||||
const [showExpandBioControl, setShowExpandBioControl] = createSignal(false)
|
||||
|
||||
const {
|
||||
actions: { loadSubscriptions },
|
||||
} = useSession()
|
||||
const author = createMemo(() => authorEntities()[props.authorSlug])
|
||||
|
||||
createEffect(async () => {
|
||||
if (author() && !author().stat) {
|
||||
await apiClient.getAuthor({ author_id: author().id })
|
||||
if (!author()?.stat) {
|
||||
console.debug(`[AuthorView] updating author...`)
|
||||
await loadAuthor({ slug: props.authorSlug })
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -92,7 +96,7 @@ export const AuthorView = (props: Props) => {
|
|||
try {
|
||||
const { authors, topics } = await fetchSubscriptions()
|
||||
setFollowing([...(authors || []), ...(topics || [])])
|
||||
const userSubscribers = await apiClient.getAuthorFollowers({ slug })
|
||||
const userSubscribers = await loadSubscriptions()
|
||||
setFollowers(userSubscribers)
|
||||
} catch (error) {
|
||||
console.error('[AuthorView] error:', error)
|
||||
|
|
|
@ -33,8 +33,6 @@ export const ProfileFormProvider = (props: { children: JSX.Element }) => {
|
|||
const { author } = useSession()
|
||||
const [form, setForm] = createStore<ProfileInput>({})
|
||||
|
||||
const currentSlug = createMemo(() => author()?.slug)
|
||||
|
||||
const submit = async (profile: ProfileInput) => {
|
||||
const response = await apiClient.updateProfile(profile)
|
||||
if (response.error) {
|
||||
|
@ -44,9 +42,8 @@ export const ProfileFormProvider = (props: { children: JSX.Element }) => {
|
|||
}
|
||||
|
||||
createEffect(async () => {
|
||||
if (!currentSlug()) return
|
||||
try {
|
||||
const currentAuthor = await loadAuthor({ slug: currentSlug() })
|
||||
if (author()) {
|
||||
const currentAuthor = author()
|
||||
setForm({
|
||||
name: currentAuthor.name,
|
||||
slug: currentAuthor.slug,
|
||||
|
@ -55,10 +52,9 @@ export const ProfileFormProvider = (props: { children: JSX.Element }) => {
|
|||
pic: userpicUrl(currentAuthor.pic),
|
||||
links: currentAuthor.links,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
|
||||
const updateFormField = (fieldName: string, value: string, remove?: boolean) => {
|
||||
if (fieldName === 'links') {
|
||||
if (remove) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { apiClient } from '../graphql/client/core'
|
|||
|
||||
export const onBeforeRender = async (pageContext: PageContext) => {
|
||||
const { slug } = pageContext.routeParams
|
||||
|
||||
console.debug(`[author.page] detected author in route: @${slug}`)
|
||||
const author = await apiClient.getAuthor({ slug })
|
||||
|
||||
if (!author) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user