Repository navigation
fix(mosaic): count resend cooldowns down from the clock - #10619
alexcarpenter wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: f3baf74 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-biometrics
@clerk/expo-google-signin
@clerk/expo-native-components
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/mosaic
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
| import { useEffect, useState } from 'react'; | ||
|
|
||
| export function useResendSeconds(resendAvailableAt: number | undefined, maxSeconds: number): number { | ||
| const [now, setNow] = useState(() => Date.now()); |
There was a problem hiding this comment.
Not SSR compatible, feels like this hook could reuse the useNow hook we built to pave the way for that in the future? Might need to add an enabled option to that hook for the countingDown case.
There was a problem hiding this comment.
Good call, done in the latest commit. useNow takes an until time and stops its timer once it reaches it (an enabled flag would need the countdown before the hook returns it), and useResendSeconds now reads the time through it, so it goes through MosaicNowProvider. I also dropped the "exception" line from docs/models.md.


Description
The add email, add phone and MFA SMS dialogs counted their resend cooldown down with a one-second
TICKevent per machine. When the tab is throttled or the device sleeps, those ticks fall behind, so Resend stays locked well past the cooldown. They now keep the unlock time in the machine, like reverification already does, and show the seconds left with a shareduseResendSecondshook.resendUnlockTime/isResendUnlocked(src/utils/verification.ts) set and check the unlock time inside each machine.useResendSeconds(src/hooks/) reads the time throughuseNow, which gains anuntiloption so its timer stops once the cooldown ends.AGENTS.mdreuse table anddocs/models.mdpoint to the new helpers.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change