about summary refs log tree commit diff
path: root/src/state/shell/reminders.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-11-15 17:17:50 -0800
committerGitHub <noreply@github.com>2023-11-15 17:17:50 -0800
commit6616b2bff098ff4a5e464c175edf2446dae0cc88 (patch)
treefb314b51dd3d17b488fa2971735aa7c19176493b /src/state/shell/reminders.ts
parentf23e9978d839322aab7304d2b6f183722e3ad4c1 (diff)
downloadvoidsky-6616b2bff098ff4a5e464c175edf2446dae0cc88.tar.zst
Shell behaviors update (react-query refactor) (#1915)
* Move tick-every-minute into a hook/context

* Move soft-reset event out of the shell model

* Update soft-reset listener on new search page

* Implement session-loaded and session-dropped events

* Update analytics and push-notifications to use new session system
Diffstat (limited to 'src/state/shell/reminders.ts')
-rw-r--r--src/state/shell/reminders.ts22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/state/shell/reminders.ts b/src/state/shell/reminders.ts
index e7ee7a5fe..88d0a5d85 100644
--- a/src/state/shell/reminders.ts
+++ b/src/state/shell/reminders.ts
@@ -1,14 +1,24 @@
 import * as persisted from '#/state/persisted'
-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) {
-  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 (isOnboardingActive()) {
@@ -22,7 +32,7 @@ export function shouldRequestEmailConfirmation(session: SessionModel) {
   // 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
   }