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