profile-fix
This commit is contained in:
parent
2bbaaa6cf1
commit
653d6771a0
|
@ -50,7 +50,7 @@ export const PasswordField = (props: Props) => {
|
||||||
on(
|
on(
|
||||||
() => error(),
|
() => error(),
|
||||||
() => {
|
() => {
|
||||||
props.errorMessage(error())
|
props.errorMessage ?? props.errorMessage(error())
|
||||||
},
|
},
|
||||||
{ defer: true },
|
{ defer: true },
|
||||||
),
|
),
|
||||||
|
|
|
@ -55,7 +55,6 @@ export const HeaderAuth = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const isEditorPage = createMemo(() => page().route === 'edit' || page().route === 'editSettings')
|
const isEditorPage = createMemo(() => page().route === 'edit' || page().route === 'editSettings')
|
||||||
|
|
||||||
const isNotificationsVisible = createMemo(() => isAuthenticated() && !isEditorPage())
|
const isNotificationsVisible = createMemo(() => isAuthenticated() && !isEditorPage())
|
||||||
const isSaveButtonVisible = createMemo(() => isAuthenticated() && isEditorPage())
|
const isSaveButtonVisible = createMemo(() => isAuthenticated() && isEditorPage())
|
||||||
const isCreatePostButtonVisible = createMemo(() => isAuthenticated() && !isEditorPage())
|
const isCreatePostButtonVisible = createMemo(() => isAuthenticated() && !isEditorPage())
|
||||||
|
|
|
@ -45,15 +45,12 @@ export const AuthorView = (props: Props) => {
|
||||||
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()?.stat) {
|
if (!author()?.stat) {
|
||||||
console.debug(`[AuthorView] updating author...`)
|
const a = await loadAuthor({ slug: props.authorSlug })
|
||||||
await loadAuthor({ slug: props.authorSlug })
|
console.debug(`[AuthorView] loaded author:`, a)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -96,8 +93,8 @@ 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 loadSubscriptions()
|
const userSubscribers = await apiClient.getAuthorFollowers({ slug })
|
||||||
setFollowers(userSubscribers)
|
setFollowers(userSubscribers || [])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[AuthorView] error:', error)
|
console.error('[AuthorView] error:', error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { apiClient } from '../graphql/client/core'
|
||||||
import { notifierClient } from '../graphql/client/notifier'
|
import { notifierClient } from '../graphql/client/notifier'
|
||||||
import { useRouter } from '../stores/router'
|
import { useRouter } from '../stores/router'
|
||||||
import { showModal } from '../stores/ui'
|
import { showModal } from '../stores/ui'
|
||||||
|
import { addAuthors } from '../stores/zine/authors'
|
||||||
import { useLocalize } from './localize'
|
import { useLocalize } from './localize'
|
||||||
import { useSnackbar } from './snackbar'
|
import { useSnackbar } from './snackbar'
|
||||||
|
|
||||||
|
@ -122,9 +122,7 @@ export const SessionProvider = (props: {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => clearTimeout(ta))
|
||||||
clearTimeout(ta)
|
|
||||||
})
|
|
||||||
|
|
||||||
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
|
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -156,7 +154,12 @@ export const SessionProvider = (props: {
|
||||||
}
|
}
|
||||||
if (!author()) {
|
if (!author()) {
|
||||||
const a = await loadAuthor()
|
const a = await loadAuthor()
|
||||||
a ? await loadSubscriptions() : reset()
|
if (a) {
|
||||||
|
await loadSubscriptions()
|
||||||
|
addAuthors([a])
|
||||||
|
} else {
|
||||||
|
reset()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setIsSessionLoaded(true)
|
setIsSessionLoaded(true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ const sortedAuthors = createLazyMemo(() => {
|
||||||
return authors
|
return authors
|
||||||
})
|
})
|
||||||
|
|
||||||
const addAuthors = (authors: Author[]) => {
|
export const addAuthors = (authors: Author[]) => {
|
||||||
const newAuthorEntities = authors.filter(Boolean).reduce(
|
const newAuthorEntities = authors.filter(Boolean).reduce(
|
||||||
(acc, author) => {
|
(acc, author) => {
|
||||||
acc[author.slug] = author
|
acc[author.slug] = author
|
||||||
|
|
Loading…
Reference in New Issue
Block a user