From 75ffb3d243a5415d173f2bca8a5334b70451a1f4 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Sat, 10 May 2025 15:08:42 -0500 Subject: Don't show NUXs to brand new users (#8362) * Ensure verification nux is only shown to older users * Update comment --- src/components/dialogs/nuxs/index.tsx | 5 ++++- src/components/dialogs/nuxs/utils.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/components/dialogs/nuxs/utils.ts (limited to 'src/components/dialogs') diff --git a/src/components/dialogs/nuxs/index.tsx b/src/components/dialogs/nuxs/index.tsx index c8c539b85..11377e1de 100644 --- a/src/components/dialogs/nuxs/index.tsx +++ b/src/components/dialogs/nuxs/index.tsx @@ -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) + }, }, ] diff --git a/src/components/dialogs/nuxs/utils.ts b/src/components/dialogs/nuxs/utils.ts new file mode 100644 index 000000000..0cc510484 --- /dev/null +++ b/src/components/dialogs/nuxs/utils.ts @@ -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 +} -- cgit 1.4.1