profile-fix

This commit is contained in:
Untone 2023-12-25 10:32:53 +03:00
parent 2bbaaa6cf1
commit 653d6771a0
5 changed files with 14 additions and 15 deletions

View File

@ -50,7 +50,7 @@ export const PasswordField = (props: Props) => {
on(
() => error(),
() => {
props.errorMessage(error())
props.errorMessage ?? props.errorMessage(error())
},
{ defer: true },
),

View File

@ -55,7 +55,6 @@ export const HeaderAuth = (props: Props) => {
}
const isEditorPage = createMemo(() => page().route === 'edit' || page().route === 'editSettings')
const isNotificationsVisible = createMemo(() => isAuthenticated() && !isEditorPage())
const isSaveButtonVisible = createMemo(() => isAuthenticated() && isEditorPage())
const isCreatePostButtonVisible = createMemo(() => isAuthenticated() && !isEditorPage())

View File

@ -45,15 +45,12 @@ export const AuthorView = (props: Props) => {
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()?.stat) {
console.debug(`[AuthorView] updating author...`)
await loadAuthor({ slug: props.authorSlug })
const a = await loadAuthor({ slug: props.authorSlug })
console.debug(`[AuthorView] loaded author:`, a)
}
})
@ -96,8 +93,8 @@ export const AuthorView = (props: Props) => {
try {
const { authors, topics } = await fetchSubscriptions()
setFollowing([...(authors || []), ...(topics || [])])
const userSubscribers = await loadSubscriptions()
setFollowers(userSubscribers)
const userSubscribers = await apiClient.getAuthorFollowers({ slug })
setFollowers(userSubscribers || [])
} catch (error) {
console.error('[AuthorView] error:', error)
}

View File

@ -27,7 +27,7 @@ import { apiClient } from '../graphql/client/core'
import { notifierClient } from '../graphql/client/notifier'
import { useRouter } from '../stores/router'
import { showModal } from '../stores/ui'
import { addAuthors } from '../stores/zine/authors'
import { useLocalize } from './localize'
import { useSnackbar } from './snackbar'
@ -122,9 +122,7 @@ export const SessionProvider = (props: {
},
)
onCleanup(() => {
clearTimeout(ta)
})
onCleanup(() => clearTimeout(ta))
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
async () => {
@ -156,7 +154,12 @@ export const SessionProvider = (props: {
}
if (!author()) {
const a = await loadAuthor()
a ? await loadSubscriptions() : reset()
if (a) {
await loadSubscriptions()
addAuthors([a])
} else {
reset()
}
}
setIsSessionLoaded(true)
}

View File

@ -33,7 +33,7 @@ const sortedAuthors = createLazyMemo(() => {
return authors
})
const addAuthors = (authors: Author[]) => {
export const addAuthors = (authors: Author[]) => {
const newAuthorEntities = authors.filter(Boolean).reduce(
(acc, author) => {
acc[author.slug] = author