post-oauth-fix

This commit is contained in:
Untone 2024-04-17 18:47:24 +03:00
parent 69fc0ffd07
commit 0f28fe891a
3 changed files with 28 additions and 15 deletions

View File

@ -55,13 +55,20 @@ export const AuthorView = (props: Props) => {
const [sessionChecked, setSessionChecked] = createSignal(false)
createEffect(() => {
if (!sessionChecked() && props.authorSlug && session()?.user?.app_data?.profile?.slug === props.authorSlug) {
if (
!sessionChecked() &&
props.authorSlug &&
session()?.user?.app_data?.profile?.slug === props.authorSlug
) {
setSessionChecked(true)
console.info('preloaded my own profile')
const { profile, authors, topics } = session().user.app_data
setFollowers(myFollowers)
setAuthor(profile)
setFollowing([...authors, ...topics])
const appdata = session()?.user.app_data
if (appdata) {
console.info('preloaded my own profile')
const { authors, followers, topics } = appdata
setFollowers(myFollowers)
setAuthor(profile)
setFollowing([...authors, ...topics])
}
}
})
@ -73,7 +80,7 @@ export const AuthorView = (props: Props) => {
const [subscriptionsResult, followersResult, authorResult] = await Promise.all([
apiClient.getAuthorFollows({ slug }),
apiClient.getAuthorFollowers({ slug }),
loadAuthor({ slug })
loadAuthor({ slug }),
])
const { authors, topics } = subscriptionsResult
setAuthor(authorResult)

View File

@ -80,10 +80,13 @@ export const FollowingProvider = (props: { children: JSX.Element }) => {
createEffect(() => {
if (author()) {
try {
const { authors, followers, topics } = session().user.app_data
setSubscriptions({ authors, topics })
setFollowers(followers)
if (!authors) fetchData()
const appdata = session()?.user.app_data
if (appdata) {
const { authors, followers, topics } = appdata
setSubscriptions({ authors, topics })
setFollowers(followers)
if (!authors) fetchData()
}
} catch (e) {
console.error(e)
}

View File

@ -220,10 +220,13 @@ export const SessionProvider = (props: {
}
try {
const { profile } = session().user.app_data
setAuthor(profile)
addAuthors([profile])
if (!profile) loadAuthor()
const appdata = session()?.user.app_data
if (appdata) {
const { profile } = appdata
setAuthor(profile)
addAuthors([profile])
if (!profile) loadAuthor()
}
} catch (e) {
console.error(e)
}