Don't show NUXs to brand new users (#8362)

* Ensure verification nux is only shown to older users

* Update comment
This commit is contained in:
Eric Bailey
2025-05-10 15:08:42 -05:00
committed by GitHub
parent d01b9ed441
commit 75ffb3d243
2 changed files with 22 additions and 1 deletions
+4 -1
View File
@@ -16,6 +16,7 @@ import {InitialVerificationAnnouncement} from '#/components/dialogs/nuxs/Initial
* NUXs
*/
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
import {isDaysOld} from '#/components/dialogs/nuxs/utils'
type Context = {
activeNux: Nux | undefined
@@ -33,7 +34,9 @@ const queuedNuxs: {
}[] = [
{
id: Nux.InitialVerificationAnnouncement,
enabled: () => true,
enabled: ({currentProfile}) => {
return isDaysOld(2, currentProfile.createdAt)
},
},
]
+18
View File
@@ -0,0 +1,18 @@
const ONE_DAY = 1000 * 60 * 60 * 24
export function isDaysOld(days: number, createdAt?: string) {
/*
* Should never happen because we gate NUXs to only accounts with a valid
* profile and a `createdAt` (see `nuxs/index.tsx`). But if it ever did, the
* account is either old enough to be pre-onboarding, or some failure happened
* during account creation. Fail closed. - esb
*/
if (!createdAt) return false
const now = Date.now()
const then = new Date(createdAt).getTime()
const isOldEnough = then + ONE_DAY * days < now
if (isOldEnough) return true
return false
}