parent
098f4b526e
commit
bc2c44cb98
|
@ -3,10 +3,8 @@ import {isObj, hasProp} from 'lib/type-guards'
|
||||||
import {RootStoreModel} from '../root-store'
|
import {RootStoreModel} from '../root-store'
|
||||||
import {toHashCode} from 'lib/strings/helpers'
|
import {toHashCode} from 'lib/strings/helpers'
|
||||||
|
|
||||||
const DAY = 60e3 * 24 * 1 // 1 day (ms)
|
|
||||||
|
|
||||||
export class Reminders {
|
export class Reminders {
|
||||||
lastEmailConfirm: Date = new Date()
|
lastEmailConfirm: Date | null = null
|
||||||
|
|
||||||
constructor(public rootStore: RootStoreModel) {
|
constructor(public rootStore: RootStoreModel) {
|
||||||
makeAutoObservable(
|
makeAutoObservable(
|
||||||
|
@ -45,6 +43,10 @@ export class Reminders {
|
||||||
if (this.rootStore.onboarding.isActive) {
|
if (this.rootStore.onboarding.isActive) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// only prompt once
|
||||||
|
if (this.lastEmailConfirm) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
// shard the users into 2 day of the week buckets
|
// shard the users into 2 day of the week buckets
|
||||||
// (this is to avoid a sudden influx of email updates when
|
// (this is to avoid a sudden influx of email updates when
|
||||||
|
@ -53,9 +55,7 @@ export class Reminders {
|
||||||
if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) {
|
if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// only ask once a day at most, but because of the bucketing
|
return true
|
||||||
// this will be more like weekly
|
|
||||||
return Number(today) - Number(this.lastEmailConfirm) > DAY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setEmailConfirmationRequested() {
|
setEmailConfirmationRequested() {
|
||||||
|
|
Loading…
Reference in New Issue