about summary refs log tree commit diff
path: root/src/components/dialogs/nuxs/utils.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2025-05-10 15:08:42 -0500
committerGitHub <noreply@github.com>2025-05-10 13:08:42 -0700
commit75ffb3d243a5415d173f2bca8a5334b70451a1f4 (patch)
treeede81969ec173d857f7ba8da0ea4370ca13d865d /src/components/dialogs/nuxs/utils.ts
parentd01b9ed44123c4182279f7be56a9e66955e342ed (diff)
downloadvoidsky-75ffb3d243a5415d173f2bca8a5334b70451a1f4.tar.zst
Don't show NUXs to brand new users (#8362)
* Ensure verification nux is only shown to older users

* Update comment
Diffstat (limited to 'src/components/dialogs/nuxs/utils.ts')
-rw-r--r--src/components/dialogs/nuxs/utils.ts18
1 files changed, 18 insertions, 0 deletions
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
+}