Remove prev NUX, add new gating util
This commit is contained in:
@@ -17,7 +17,7 @@ import {InitialVerificationAnnouncement} from '#/components/dialogs/nuxs/Initial
|
|||||||
* NUXs
|
* NUXs
|
||||||
*/
|
*/
|
||||||
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
|
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
|
||||||
import {isDaysOld} from '#/components/dialogs/nuxs/utils'
|
import {isExistingUserAsOf} from '#/components/dialogs/nuxs/utils'
|
||||||
|
|
||||||
type Context = {
|
type Context = {
|
||||||
activeNux: Nux | undefined
|
activeNux: Nux | undefined
|
||||||
@@ -33,16 +33,14 @@ const queuedNuxs: {
|
|||||||
preferences: UsePreferencesQueryResponse
|
preferences: UsePreferencesQueryResponse
|
||||||
}) => boolean
|
}) => boolean
|
||||||
}[] = [
|
}[] = [
|
||||||
{
|
|
||||||
id: Nux.InitialVerificationAnnouncement,
|
|
||||||
enabled: ({currentProfile}) => {
|
|
||||||
return isDaysOld(2, currentProfile.createdAt)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: Nux.ActivityNotificationsAnnouncement,
|
id: Nux.ActivityNotificationsAnnouncement,
|
||||||
enabled: ({currentProfile}) => {
|
enabled: ({currentProfile}) => {
|
||||||
return isDaysOld(2, currentProfile.createdAt)
|
// TODO just filler rn
|
||||||
|
return isExistingUserAsOf(
|
||||||
|
'2025-06-17T00:00:00.000Z',
|
||||||
|
currentProfile.createdAt,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -16,3 +16,18 @@ export function isDaysOld(days: number, createdAt?: string) {
|
|||||||
if (isOldEnough) return true
|
if (isOldEnough) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isExistingUserAsOf(date: string, 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 threshold = Date.parse(date)
|
||||||
|
const then = new Date(createdAt).getTime()
|
||||||
|
|
||||||
|
return then < threshold
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user