diff options
Diffstat (limited to 'src/state/models/ui')
-rw-r--r-- | src/state/models/ui/reminders.e2e.ts | 24 | ||||
-rw-r--r-- | src/state/models/ui/reminders.ts | 12 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/state/models/ui/reminders.e2e.ts b/src/state/models/ui/reminders.e2e.ts new file mode 100644 index 000000000..ec0eca40d --- /dev/null +++ b/src/state/models/ui/reminders.e2e.ts @@ -0,0 +1,24 @@ +import {makeAutoObservable} from 'mobx' +import {RootStoreModel} from '../root-store' + +export class Reminders { + constructor(public rootStore: RootStoreModel) { + makeAutoObservable( + this, + {serialize: false, hydrate: false}, + {autoBind: true}, + ) + } + + serialize() { + return {} + } + + hydrate(_v: unknown) {} + + get shouldRequestEmailConfirmation() { + return false + } + + setEmailConfirmationRequested() {} +} diff --git a/src/state/models/ui/reminders.ts b/src/state/models/ui/reminders.ts index 60dbf5d88..c650de004 100644 --- a/src/state/models/ui/reminders.ts +++ b/src/state/models/ui/reminders.ts @@ -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( @@ -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 @@ -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() { |