Merge remote-tracking branch 'origin/main' into starter-packs
This commit is contained in:
+2
-2
@@ -56,8 +56,8 @@ import {useModalControls} from './state/modals'
|
|||||||
import {useUnreadNotifications} from './state/queries/notifications/unread'
|
import {useUnreadNotifications} from './state/queries/notifications/unread'
|
||||||
import {useSession} from './state/session'
|
import {useSession} from './state/session'
|
||||||
import {
|
import {
|
||||||
setEmailConfirmationRequested,
|
|
||||||
shouldRequestEmailConfirmation,
|
shouldRequestEmailConfirmation,
|
||||||
|
snoozeEmailConfirmationPrompt,
|
||||||
} from './state/shell/reminders'
|
} from './state/shell/reminders'
|
||||||
import {AccessibilitySettingsScreen} from './view/screens/AccessibilitySettings'
|
import {AccessibilitySettingsScreen} from './view/screens/AccessibilitySettings'
|
||||||
import {CommunityGuidelinesScreen} from './view/screens/CommunityGuidelines'
|
import {CommunityGuidelinesScreen} from './view/screens/CommunityGuidelines'
|
||||||
@@ -597,7 +597,7 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
|||||||
|
|
||||||
if (currentAccount && shouldRequestEmailConfirmation(currentAccount)) {
|
if (currentAccount && shouldRequestEmailConfirmation(currentAccount)) {
|
||||||
openModal({name: 'verify-email', showReminder: true})
|
openModal({name: 'verify-email', showReminder: true})
|
||||||
setEmailConfirmationRequested()
|
snoozeEmailConfirmationPrompt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,14 @@ export function getAge(birthDate: Date): number {
|
|||||||
}
|
}
|
||||||
return age
|
return age
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two dates by year, month, and day only
|
||||||
|
*/
|
||||||
|
export function simpleAreDatesEqual(a: Date, b: Date): boolean {
|
||||||
|
return (
|
||||||
|
a.getFullYear() === b.getFullYear() &&
|
||||||
|
a.getMonth() === b.getMonth() &&
|
||||||
|
a.getDate() === b.getDate()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ let ProfileHeaderLabeler = ({
|
|||||||
preferences?.moderationPrefs.labelers.find(l => l.did === profile.did)
|
preferences?.moderationPrefs.labelers.find(l => l.did === profile.did)
|
||||||
const canSubscribe =
|
const canSubscribe =
|
||||||
isSubscribed ||
|
isSubscribed ||
|
||||||
(preferences ? preferences?.moderationPrefs.labelers.length < 9 : false)
|
(preferences ? preferences?.moderationPrefs.labelers.length <= 20 : false)
|
||||||
const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation()
|
const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation()
|
||||||
const {mutateAsync: unlikeMod, isPending: isUnlikePending} =
|
const {mutateAsync: unlikeMod, isPending: isUnlikePending} =
|
||||||
useUnlikeMutation()
|
useUnlikeMutation()
|
||||||
@@ -328,8 +328,8 @@ function CantSubscribePrompt({
|
|||||||
<Prompt.TitleText>Unable to subscribe</Prompt.TitleText>
|
<Prompt.TitleText>Unable to subscribe</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText>
|
||||||
<Trans>
|
<Trans>
|
||||||
We're sorry! You can only subscribe to ten labelers, and you've
|
We're sorry! You can only subscribe to twenty labelers, and you've
|
||||||
reached your limit of ten.
|
reached your limit of twenty.
|
||||||
</Trans>
|
</Trans>
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
<Prompt.Actions>
|
<Prompt.Actions>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import {tryFetchGates} from '#/lib/statsig/statsig'
|
import {tryFetchGates} from '#/lib/statsig/statsig'
|
||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
|
||||||
import {
|
import {
|
||||||
configureModerationForAccount,
|
configureModerationForAccount,
|
||||||
configureModerationForGuest,
|
configureModerationForGuest,
|
||||||
@@ -191,6 +192,13 @@ export async function createAgentAndCreateAccount(
|
|||||||
agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// snooze first prompt after signup, defer to next prompt
|
||||||
|
snoozeEmailConfirmationPrompt()
|
||||||
|
} catch (e: any) {
|
||||||
|
logger.error(e, {context: `session: failed snoozeEmailConfirmationPrompt`})
|
||||||
|
}
|
||||||
|
|
||||||
return prepareAgent(agent, gates, moderation, onSessionChange)
|
return prepareAgent(agent, gates, moderation, onSessionChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
export function init() {}
|
|
||||||
|
|
||||||
export function shouldRequestEmailConfirmation() {
|
export function shouldRequestEmailConfirmation() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setEmailConfirmationRequested() {}
|
export function snoozeEmailConfirmationPrompt() {}
|
||||||
|
|||||||
@@ -1,36 +1,45 @@
|
|||||||
|
import {simpleAreDatesEqual} from '#/lib/strings/time'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {toHashCode} from 'lib/strings/helpers'
|
|
||||||
import {isOnboardingActive} from './onboarding'
|
|
||||||
import {SessionAccount} from '../session'
|
import {SessionAccount} from '../session'
|
||||||
|
import {isOnboardingActive} from './onboarding'
|
||||||
|
|
||||||
export function shouldRequestEmailConfirmation(account: SessionAccount) {
|
export function shouldRequestEmailConfirmation(account: SessionAccount) {
|
||||||
if (!account) {
|
// ignore logged out
|
||||||
return false
|
if (!account) return false
|
||||||
}
|
// ignore confirmed accounts, this is the success state of this reminder
|
||||||
if (account.emailConfirmed) {
|
if (account.emailConfirmed) return false
|
||||||
return false
|
// wait for onboarding to complete
|
||||||
}
|
if (isOnboardingActive()) return false
|
||||||
if (isOnboardingActive()) {
|
|
||||||
return false
|
const snoozedAt = persisted.get('reminders').lastEmailConfirm
|
||||||
}
|
|
||||||
// only prompt once
|
|
||||||
if (persisted.get('reminders').lastEmailConfirm) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const today = new Date()
|
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
|
logger.debug('Checking email confirmation reminder', {
|
||||||
// this feature rolls out)
|
today,
|
||||||
const code = toHashCode(account.did) % 7
|
snoozedAt,
|
||||||
if (code !== today.getDay() && code !== (today.getDay() + 1) % 7) {
|
})
|
||||||
|
|
||||||
|
// never been snoozed, new account
|
||||||
|
if (!snoozedAt) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// already snoozed today
|
||||||
|
if (simpleAreDatesEqual(new Date(Date.parse(snoozedAt)), new Date())) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setEmailConfirmationRequested() {
|
export function snoozeEmailConfirmationPrompt() {
|
||||||
|
const lastEmailConfirm = new Date().toISOString()
|
||||||
|
logger.debug('Snoozing email confirmation reminder', {
|
||||||
|
snoozedAt: lastEmailConfirm,
|
||||||
|
})
|
||||||
persisted.write('reminders', {
|
persisted.write('reminders', {
|
||||||
...persisted.get('reminders'),
|
...persisted.get('reminders'),
|
||||||
lastEmailConfirm: new Date().toISOString(),
|
lastEmailConfirm,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user