[APP-1882] fix email not updating in session state after email change (#9953)
This commit is contained in:
@@ -284,6 +284,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
type: 'partial-refresh-session',
|
||||
accountDid: agent.session!.did,
|
||||
patch: {
|
||||
email: data.email,
|
||||
emailConfirmed: data.emailConfirmed,
|
||||
emailAuthFactor: data.emailAuthFactor,
|
||||
},
|
||||
|
||||
@@ -58,7 +58,10 @@ export type Action =
|
||||
| {
|
||||
type: 'partial-refresh-session'
|
||||
accountDid: string
|
||||
patch: Pick<SessionAccount, 'emailConfirmed' | 'emailAuthFactor'>
|
||||
patch: Pick<
|
||||
SessionAccount,
|
||||
'email' | 'emailConfirmed' | 'emailAuthFactor'
|
||||
>
|
||||
}
|
||||
|
||||
function createPublicAgentState(): AgentState {
|
||||
@@ -239,6 +242,7 @@ let reducer = (state: State, action: Action): State => {
|
||||
* Only mutating values that are safe. Be very careful with this.
|
||||
*/
|
||||
if (agent.session) {
|
||||
agent.session.email = patch.email ?? agent.session.email
|
||||
agent.session.emailConfirmed =
|
||||
patch.emailConfirmed ?? agent.session.emailConfirmed
|
||||
agent.session.emailAuthFactor =
|
||||
@@ -255,6 +259,7 @@ let reducer = (state: State, action: Action): State => {
|
||||
if (a.did === accountDid) {
|
||||
return {
|
||||
...a,
|
||||
email: patch.email ?? a.email,
|
||||
emailConfirmed: patch.emailConfirmed ?? a.emailConfirmed,
|
||||
emailAuthFactor: patch.emailAuthFactor ?? a.emailAuthFactor,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user