diff options
Diffstat (limited to 'src/state/shell/reminders.ts')
-rw-r--r-- | src/state/shell/reminders.ts | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/state/shell/reminders.ts b/src/state/shell/reminders.ts index d68a272ac..88d0a5d85 100644 --- a/src/state/shell/reminders.ts +++ b/src/state/shell/reminders.ts @@ -1,20 +1,27 @@ import * as persisted from '#/state/persisted' -import {OnboardingModel} from '../models/discovery/onboarding' -import {SessionModel} from '../models/session' import {toHashCode} from 'lib/strings/helpers' +import {isOnboardingActive} from './onboarding' +import {SessionAccount} from '../session' +import {listenSessionLoaded} from '../events' +import {unstable__openModal} from '../modals' -export function shouldRequestEmailConfirmation( - session: SessionModel, - onboarding: OnboardingModel, -) { - const sess = session.currentSession - if (!sess) { +export function init() { + listenSessionLoaded(account => { + if (shouldRequestEmailConfirmation(account)) { + unstable__openModal({name: 'verify-email', showReminder: true}) + setEmailConfirmationRequested() + } + }) +} + +export function shouldRequestEmailConfirmation(account: SessionAccount) { + if (!account) { return false } - if (sess.emailConfirmed) { + if (account.emailConfirmed) { return false } - if (onboarding.isActive) { + if (isOnboardingActive()) { return false } // only prompt once @@ -25,7 +32,7 @@ export function shouldRequestEmailConfirmation( // shard the users into 2 day of the week buckets // (this is to avoid a sudden influx of email updates when // this feature rolls out) - const code = toHashCode(sess.did) % 7 + const code = toHashCode(account.did) % 7 if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) { return false } |