Skip to content

Commit

Permalink
Only prompt users once to verify email (according to local storage) c…
Browse files Browse the repository at this point in the history
…lose #1657 (#1658)
  • Loading branch information
pfrazee authored Oct 10, 2023
1 parent 098f4b5 commit bc2c44c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/state/models/ui/reminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {isObj, hasProp} from 'lib/type-guards'
import {RootStoreModel} from '../root-store'
import {toHashCode} from 'lib/strings/helpers'

const DAY = 60e3 * 24 * 1 // 1 day (ms)

export class Reminders {
lastEmailConfirm: Date = new Date()
lastEmailConfirm: Date | null = null

constructor(public rootStore: RootStoreModel) {
makeAutoObservable(
Expand Down Expand Up @@ -45,6 +43,10 @@ export class Reminders {
if (this.rootStore.onboarding.isActive) {
return false
}
// only prompt once
if (this.lastEmailConfirm) {
return false
}
const today = new Date()
// shard the users into 2 day of the week buckets
// (this is to avoid a sudden influx of email updates when
Expand All @@ -53,9 +55,7 @@ export class Reminders {
if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) {
return false
}
// only ask once a day at most, but because of the bucketing
// this will be more like weekly
return Number(today) - Number(this.lastEmailConfirm) > DAY
return true
}

setEmailConfirmationRequested() {
Expand Down

0 comments on commit bc2c44c

Please sign in to comment.