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,14 +55,21 @@ export const AuthorView = (props: Props) => {
const [sessionChecked, setSessionChecked] = createSignal(false) const [sessionChecked, setSessionChecked] = createSignal(false)
createEffect(() => { 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) setSessionChecked(true)
const appdata = session()?.user.app_data
if (appdata) {
console.info('preloaded my own profile') console.info('preloaded my own profile')
const { profile, authors, topics } = session().user.app_data const { authors, followers, topics } = appdata
setFollowers(myFollowers) setFollowers(myFollowers)
setAuthor(profile) setAuthor(profile)
setFollowing([...authors, ...topics]) setFollowing([...authors, ...topics])
} }
}
}) })
const bioContainerRef: { current: HTMLDivElement } = { current: null } const bioContainerRef: { current: HTMLDivElement } = { current: null }
@ -73,7 +80,7 @@ export const AuthorView = (props: Props) => {
const [subscriptionsResult, followersResult, authorResult] = await Promise.all([ const [subscriptionsResult, followersResult, authorResult] = await Promise.all([
apiClient.getAuthorFollows({ slug }), apiClient.getAuthorFollows({ slug }),
apiClient.getAuthorFollowers({ slug }), apiClient.getAuthorFollowers({ slug }),
loadAuthor({ slug }) loadAuthor({ slug }),
]) ])
const { authors, topics } = subscriptionsResult const { authors, topics } = subscriptionsResult
setAuthor(authorResult) setAuthor(authorResult)

View File

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

View File

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