Fix session email/emailConfirmed types, update usage for safer access
This commit is contained in:
@@ -66,7 +66,6 @@ type LegacySchema = {
|
||||
|
||||
const DEPRECATED_ROOT_STATE_STORAGE_KEY = 'root'
|
||||
|
||||
// TODO remove, assume that partial data may be here during our refactor
|
||||
export function transform(legacy: Partial<LegacySchema>): Schema {
|
||||
return {
|
||||
colorMode: legacy.shell?.colorMode || defaults.colorMode,
|
||||
|
||||
@@ -2,17 +2,14 @@ import {z} from 'zod'
|
||||
import {deviceLocales} from '#/platform/detection'
|
||||
|
||||
// only data needed for rendering account page
|
||||
// TODO agent.resumeSession requires the following fields
|
||||
const accountSchema = z.object({
|
||||
service: z.string(),
|
||||
did: z.string(),
|
||||
handle: z.string(),
|
||||
email: z.string(),
|
||||
emailConfirmed: z.boolean(),
|
||||
email: z.string().optional(),
|
||||
emailConfirmed: z.boolean().optional(),
|
||||
refreshJwt: z.string().optional(), // optional because it can expire
|
||||
accessJwt: z.string().optional(), // optional because it can expire
|
||||
// displayName: z.string().optional(),
|
||||
// aviUrl: z.string().optional(),
|
||||
})
|
||||
export type PersistedAccount = z.infer<typeof accountSchema>
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
service: agent.service.toString(),
|
||||
did: agent.session.did,
|
||||
handle: agent.session.handle,
|
||||
email: agent.session.email!, // TODO this is always defined?
|
||||
email: agent.session.email,
|
||||
emailConfirmed: agent.session.emailConfirmed || false,
|
||||
refreshJwt: agent.session.refreshJwt,
|
||||
accessJwt: agent.session.accessJwt,
|
||||
@@ -342,7 +342,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
service: agent.service.toString(),
|
||||
did: agent.session.did,
|
||||
handle: agent.session.handle,
|
||||
email: agent.session.email!, // TODO this is always defined?
|
||||
email: agent.session.email,
|
||||
emailConfirmed: agent.session.emailConfirmed || false,
|
||||
refreshJwt: agent.session.refreshJwt,
|
||||
accessJwt: agent.session.accessJwt,
|
||||
|
||||
@@ -118,8 +118,8 @@ export function Component() {
|
||||
) : stage === Stages.ConfirmCode ? (
|
||||
<Trans>
|
||||
An email has been sent to your previous address,{' '}
|
||||
{currentAccount?.email || ''}. It includes a confirmation code
|
||||
which you can enter below.
|
||||
{currentAccount?.email || '(no email)'}. It includes a
|
||||
confirmation code which you can enter below.
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans>
|
||||
|
||||
@@ -108,8 +108,8 @@ export function Component({showReminder}: {showReminder?: boolean}) {
|
||||
</Trans>
|
||||
) : stage === Stages.ConfirmCode ? (
|
||||
<Trans>
|
||||
An email has been sent to {currentAccount?.email || ''}. It
|
||||
includes a confirmation code which you can enter below.
|
||||
An email has been sent to {currentAccount?.email || '(no email)'}.
|
||||
It includes a confirmation code which you can enter below.
|
||||
</Trans>
|
||||
) : (
|
||||
''
|
||||
@@ -125,7 +125,7 @@ export function Component({showReminder}: {showReminder?: boolean}) {
|
||||
size={16}
|
||||
/>
|
||||
<Text type="xl-medium" style={[pal.text, s.flex1, {minWidth: 0}]}>
|
||||
{currentAccount?.email || ''}
|
||||
{currentAccount?.email || '(no email)'}
|
||||
</Text>
|
||||
</View>
|
||||
<Pressable
|
||||
|
||||
@@ -299,7 +299,7 @@ export function SettingsScreen({}: Props) {
|
||||
</>
|
||||
)}
|
||||
<Text type="lg" style={pal.text}>
|
||||
{currentAccount.email}{' '}
|
||||
{currentAccount.email || '(no email)'}{' '}
|
||||
</Text>
|
||||
<Link onPress={() => openModal({name: 'change-email'})}>
|
||||
<Text type="lg" style={pal.link}>
|
||||
|
||||
@@ -58,8 +58,8 @@ export function DesktopRightNav() {
|
||||
type="md"
|
||||
style={pal.link}
|
||||
href={FEEDBACK_FORM_URL({
|
||||
email: currentAccount!.email,
|
||||
handle: currentAccount!.handle,
|
||||
email: currentAccount?.email,
|
||||
handle: currentAccount?.handle,
|
||||
})}
|
||||
text={_(msg`Feedback`)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user