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