An ATproto social media client -- with an independent Appview.

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

* Ensure verification nux is only shown to older users

* Update comment

authored by

Eric Bailey and committed by
GitHub
75ffb3d2 d01b9ed4

+22 -1
+4 -1
src/components/dialogs/nuxs/index.tsx
··· 16 16 * NUXs 17 17 */ 18 18 import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing' 19 + import {isDaysOld} from '#/components/dialogs/nuxs/utils' 19 20 20 21 type Context = { 21 22 activeNux: Nux | undefined ··· 33 34 }[] = [ 34 35 { 35 36 id: Nux.InitialVerificationAnnouncement, 36 - enabled: () => true, 37 + enabled: ({currentProfile}) => { 38 + return isDaysOld(2, currentProfile.createdAt) 39 + }, 37 40 }, 38 41 ] 39 42
+18
src/components/dialogs/nuxs/utils.ts
··· 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 + }