Fixes to session management (#117)
* Update session-management to solve incorrectly dropped sessions * Reset the nav on account switch * Reset the feed on me.load() * Update tests to reflect new account-switching behavior
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
} from 'react-native'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import * as EmailValidator from 'email-validator'
|
||||
import {sessionClient as AtpApi, SessionServiceClient} from '@atproto/api'
|
||||
import AtpApi from '@atproto/api'
|
||||
import {useAnalytics} from '@segment/analytics-react-native'
|
||||
import {LogoTextHero} from './Logo'
|
||||
import {Text} from '../util/text/Text'
|
||||
@@ -471,7 +471,7 @@ const ForgotPasswordForm = ({
|
||||
setIsProcessing(true)
|
||||
|
||||
try {
|
||||
const api = AtpApi.service(serviceUrl) as SessionServiceClient
|
||||
const api = AtpApi.service(serviceUrl)
|
||||
await api.com.atproto.account.requestPasswordReset({email})
|
||||
onEmailSent()
|
||||
} catch (e: any) {
|
||||
@@ -602,7 +602,7 @@ const SetNewPasswordForm = ({
|
||||
setIsProcessing(true)
|
||||
|
||||
try {
|
||||
const api = AtpApi.service(serviceUrl) as SessionServiceClient
|
||||
const api = AtpApi.service(serviceUrl)
|
||||
await api.com.atproto.account.resetPassword({token: resetCode, password})
|
||||
onPasswordSet()
|
||||
} catch (e: any) {
|
||||
|
||||
@@ -69,7 +69,7 @@ export const Home = observer(function Home({
|
||||
store.me.mainFeed.setup()
|
||||
}
|
||||
return cleanup
|
||||
}, [visible, store, navIdx, doPoll, wasVisible])
|
||||
}, [visible, store, store.me.mainFeed, navIdx, doPoll, wasVisible])
|
||||
|
||||
const onPressCompose = (imagesOpen?: boolean) => {
|
||||
store.shell.openComposer({imagesOpen})
|
||||
|
||||
@@ -39,11 +39,13 @@ export const Settings = observer(function Settings({
|
||||
setIsSwitching(true)
|
||||
if (await store.session.resumeSession(acct)) {
|
||||
setIsSwitching(false)
|
||||
store.nav.tab.fixedTabReset()
|
||||
Toast.show(`Signed in as ${acct.displayName || acct.handle}`)
|
||||
return
|
||||
}
|
||||
setIsSwitching(false)
|
||||
Toast.show('Sorry! We need you to enter your password.')
|
||||
store.nav.tab.fixedTabReset()
|
||||
store.session.clear()
|
||||
}
|
||||
const onPressAddAccount = () => {
|
||||
|
||||
Reference in New Issue
Block a user