Skip to content

Commit

Permalink
Remove unsafe update in sentVerificationEmail reducer (#19364)
Browse files Browse the repository at this point in the history
  • Loading branch information
buoyad committed Sep 12, 2019
1 parent dd401f2 commit 4931602
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions shared/reducers/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,18 @@ function reducer(state: Types.State = initialState, action: Actions): Types.Stat
)
}
case SettingsGen.sentVerificationEmail: {
return state
.update('email', emailState =>
emailState.merge({
addedEmail: action.payload.email,
})
)
.updateIn(['email', 'emails'], emails => {
return emails.update(action.payload.email, email =>
email.merge({
lastVerifyEmailDate: new Date().getTime() / 1000,
})
)
return state.update('email', emailState =>
emailState.merge({
addedEmail: action.payload.email,
emails: (emailState.emails || I.Map<string, Types.EmailRow>()).update(
action.payload.email,
(email = Constants.makeEmailRow({email: action.payload.email, isVerified: false})) =>
email.merge({
lastVerifyEmailDate: new Date().getTime() / 1000,
})
),
})
)
}
case SettingsGen.clearAddingEmail: {
return state.update('email', emailState => emailState.merge({addingEmail: null, error: ''}))
Expand Down

0 comments on commit 4931602

Please sign in to comment.