Skip to content

Commit 75ffb3d

Browse files
Don't show NUXs to brand new users (#8362)
* Ensure verification nux is only shown to older users * Update comment
1 parent d01b9ed commit 75ffb3d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/components/dialogs/nuxs/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {InitialVerificationAnnouncement} from '#/components/dialogs/nuxs/Initial
1616
* NUXs
1717
*/
1818
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
19+
import {isDaysOld} from '#/components/dialogs/nuxs/utils'
1920

2021
type Context = {
2122
activeNux: Nux | undefined
@@ -33,7 +34,9 @@ const queuedNuxs: {
3334
}[] = [
3435
{
3536
id: Nux.InitialVerificationAnnouncement,
36-
enabled: () => true,
37+
enabled: ({currentProfile}) => {
38+
return isDaysOld(2, currentProfile.createdAt)
39+
},
3740
},
3841
]
3942

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const ONE_DAY = 1000 * 60 * 60 * 24
2+
3+
export function isDaysOld(days: number, createdAt?: string) {
4+
/*
5+
* Should never happen because we gate NUXs to only accounts with a valid
6+
* profile and a `createdAt` (see `nuxs/index.tsx`). But if it ever did, the
7+
* account is either old enough to be pre-onboarding, or some failure happened
8+
* during account creation. Fail closed. - esb
9+
*/
10+
if (!createdAt) return false
11+
12+
const now = Date.now()
13+
const then = new Date(createdAt).getTime()
14+
const isOldEnough = then + ONE_DAY * days < now
15+
16+
if (isOldEnough) return true
17+
return false
18+
}

0 commit comments

Comments
 (0)