Add back deprecated updateCurrentAccount and revert usages (#3540)
This commit is contained in:
@@ -371,6 +371,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
upsertAndPersistAccount,
|
||||
])
|
||||
|
||||
const updateCurrentAccount = React.useCallback(async () => {
|
||||
await refreshSession()
|
||||
}, [refreshSession])
|
||||
|
||||
const selectAccount = React.useCallback<SessionApiContext['selectAccount']>(
|
||||
async (account, logContext) => {
|
||||
setIsSwitchingAccounts(true)
|
||||
@@ -504,6 +508,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
selectAccount,
|
||||
refreshSession,
|
||||
clearCurrentAccount,
|
||||
updateCurrentAccount,
|
||||
}),
|
||||
[
|
||||
createAccount,
|
||||
@@ -515,6 +520,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
selectAccount,
|
||||
refreshSession,
|
||||
clearCurrentAccount,
|
||||
updateCurrentAccount,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -77,4 +77,12 @@ export type SessionApiContext = {
|
||||
* Refreshes the BskyAgent's session and derive a fresh `currentAccount`
|
||||
*/
|
||||
refreshSession: () => void
|
||||
/**
|
||||
* @deprecated Use `refreshSession` instead.
|
||||
*/
|
||||
updateCurrentAccount: (
|
||||
account: Partial<
|
||||
Pick<SessionAccount, 'handle' | 'email' | 'emailConfirmed'>
|
||||
>,
|
||||
) => void
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export const snapPoints = ['90%']
|
||||
export function Component() {
|
||||
const pal = usePalette('default')
|
||||
const {currentAccount} = useSession()
|
||||
const {refreshSession} = useSessionApi()
|
||||
const {updateCurrentAccount} = useSessionApi()
|
||||
const {_} = useLingui()
|
||||
const [stage, setStage] = useState<Stages>(Stages.InputEmail)
|
||||
const [email, setEmail] = useState<string>(currentAccount?.email || '')
|
||||
@@ -50,7 +50,10 @@ export function Component() {
|
||||
setStage(Stages.ConfirmCode)
|
||||
} else {
|
||||
await getAgent().com.atproto.server.updateEmail({email: email.trim()})
|
||||
refreshSession()
|
||||
updateCurrentAccount({
|
||||
email: email.trim(),
|
||||
emailConfirmed: false,
|
||||
})
|
||||
Toast.show(_(msg`Email updated`))
|
||||
setStage(Stages.Done)
|
||||
}
|
||||
@@ -79,7 +82,10 @@ export function Component() {
|
||||
email: email.trim(),
|
||||
token: confirmationCode.trim(),
|
||||
})
|
||||
refreshSession()
|
||||
updateCurrentAccount({
|
||||
email: email.trim(),
|
||||
emailConfirmed: false,
|
||||
})
|
||||
Toast.show(_(msg`Email updated`))
|
||||
setStage(Stages.Done)
|
||||
} catch (e) {
|
||||
|
||||
@@ -72,7 +72,7 @@ export function Inner({
|
||||
const {_} = useLingui()
|
||||
const pal = usePalette('default')
|
||||
const {track} = useAnalytics()
|
||||
const {refreshSession} = useSessionApi()
|
||||
const {updateCurrentAccount} = useSessionApi()
|
||||
const {closeModal} = useModalControls()
|
||||
const {mutateAsync: updateHandle, isPending: isUpdateHandlePending} =
|
||||
useUpdateHandleMutation()
|
||||
@@ -115,7 +115,9 @@ export function Inner({
|
||||
await updateHandle({
|
||||
handle: newHandle,
|
||||
})
|
||||
refreshSession()
|
||||
updateCurrentAccount({
|
||||
handle: newHandle,
|
||||
})
|
||||
closeModal()
|
||||
onChanged()
|
||||
} catch (err: any) {
|
||||
@@ -131,7 +133,7 @@ export function Inner({
|
||||
onChanged,
|
||||
track,
|
||||
closeModal,
|
||||
refreshSession,
|
||||
updateCurrentAccount,
|
||||
updateHandle,
|
||||
serviceInfo,
|
||||
])
|
||||
|
||||
@@ -36,7 +36,7 @@ enum Stages {
|
||||
export function Component({showReminder}: {showReminder?: boolean}) {
|
||||
const pal = usePalette('default')
|
||||
const {currentAccount} = useSession()
|
||||
const {refreshSession} = useSessionApi()
|
||||
const {updateCurrentAccount} = useSessionApi()
|
||||
const {_} = useLingui()
|
||||
const [stage, setStage] = useState<Stages>(
|
||||
showReminder ? Stages.Reminder : Stages.Email,
|
||||
@@ -75,7 +75,7 @@ export function Component({showReminder}: {showReminder?: boolean}) {
|
||||
email: (currentAccount?.email || '').trim(),
|
||||
token: confirmationCode.trim(),
|
||||
})
|
||||
refreshSession()
|
||||
updateCurrentAccount({emailConfirmed: true})
|
||||
Toast.show(_(msg`Email verified`))
|
||||
closeModal()
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user