Add fallback to email reminder modal (#2193)

* Add fallback to email reminder modal

* Add more debug
zio/stable
Eric Bailey 2023-12-12 17:18:38 -06:00 committed by GitHub
parent bf9cedb67b
commit b1f9454f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -361,6 +361,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
} }
if (canReusePrevSession) { if (canReusePrevSession) {
logger.info(`session: attempting to reuse previous session`)
agent.session = prevSession agent.session = prevSession
__globalAgent = agent __globalAgent = agent
queryClient.clear() queryClient.clear()
@ -370,6 +372,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
resumeSessionWithFreshAccount() resumeSessionWithFreshAccount()
.then(freshAccount => { .then(freshAccount => {
if (JSON.stringify(account) !== JSON.stringify(freshAccount)) { if (JSON.stringify(account) !== JSON.stringify(freshAccount)) {
logger.info(
`session: reuse of previous session returned a fresh account, upserting`,
)
upsertAccount(freshAccount) upsertAccount(freshAccount)
} }
}) })
@ -385,6 +390,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
__globalAgent = PUBLIC_BSKY_AGENT __globalAgent = PUBLIC_BSKY_AGENT
}) })
} else { } else {
logger.info(`session: attempting to resume using previous session`)
try { try {
const freshAccount = await resumeSessionWithFreshAccount() const freshAccount = await resumeSessionWithFreshAccount()
__globalAgent = agent __globalAgent = agent
@ -404,6 +411,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
} }
async function resumeSessionWithFreshAccount(): Promise<SessionAccount> { async function resumeSessionWithFreshAccount(): Promise<SessionAccount> {
logger.info(`session: resumeSessionWithFreshAccount`)
await networkRetry(1, () => agent.resumeSession(prevSession)) await networkRetry(1, () => agent.resumeSession(prevSession))
/* /*

View File

@ -22,6 +22,7 @@ import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
import {useSession, useSessionApi, getAgent} from '#/state/session' import {useSession, useSessionApi, getAgent} from '#/state/session'
import {logger} from '#/logger'
export const snapPoints = ['90%'] export const snapPoints = ['90%']
@ -45,6 +46,13 @@ export function Component({showReminder}: {showReminder?: boolean}) {
const {isMobile} = useWebMediaQueries() const {isMobile} = useWebMediaQueries()
const {openModal, closeModal} = useModalControls() const {openModal, closeModal} = useModalControls()
React.useEffect(() => {
if (!currentAccount) {
logger.error(`VerifyEmail modal opened without currentAccount`)
closeModal()
}
}, [currentAccount, closeModal])
const onSendEmail = async () => { const onSendEmail = async () => {
setError('') setError('')
setIsProcessing(true) setIsProcessing(true)