-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move reminders to new persisted state layer
- Loading branch information
Showing
8 changed files
with
66 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {OnboardingModel} from '../models/discovery/onboarding' | ||
import {SessionModel} from '../models/session' | ||
|
||
export function shouldRequestEmailConfirmation( | ||
_session: SessionModel, | ||
_onboarding: OnboardingModel, | ||
) { | ||
return false | ||
} | ||
|
||
export function setEmailConfirmationRequested() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as persisted from '#/state/persisted' | ||
import {OnboardingModel} from '../models/discovery/onboarding' | ||
import {SessionModel} from '../models/session' | ||
import {toHashCode} from 'lib/strings/helpers' | ||
|
||
export function shouldRequestEmailConfirmation( | ||
session: SessionModel, | ||
onboarding: OnboardingModel, | ||
) { | ||
const sess = session.currentSession | ||
if (!sess) { | ||
return false | ||
} | ||
if (sess.emailConfirmed) { | ||
return false | ||
} | ||
if (onboarding.isActive) { | ||
return false | ||
} | ||
// only prompt once | ||
if (persisted.get('reminders').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 | ||
// this feature rolls out) | ||
const code = toHashCode(sess.did) % 7 | ||
if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
export function setEmailConfirmationRequested() { | ||
persisted.write('reminders', { | ||
...persisted.get('reminders'), | ||
lastEmailConfirm: new Date().toISOString(), | ||
}) | ||
} |