Skip to content

Commit e3556e8

Browse files
authored
feat(desktop): add email verification prompt and translation support (#3266)
1 parent 9ac2e16 commit e3556e8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

apps/desktop/locales/settings/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
"profile.email.unverified": "Unverified",
298298
"profile.email.verification_sent": "Email verification sent",
299299
"profile.email.verified": "Verified",
300+
"profile.email.verify_email": "Please verify your email ({{email_address}}) to continue",
300301
"profile.handle.description": "Your unique identifier.",
301302
"profile.handle.label": "Handle",
302303
"profile.link_social.authentication": "Authentication",

apps/desktop/locales/settings/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
"profile.email.unverified": "未验证",
295295
"profile.email.verification_sent": "验证邮件已发送。",
296296
"profile.email.verified": "已验证",
297+
"profile.email.verify_email": "请认证你的邮箱地址 ({{email_address}}) 以继续。",
297298
"profile.handle.description": "你的唯一标识。",
298299
"profile.handle.label": "唯一标识",
299300
"profile.link_social.authentication": "身份验证",

apps/desktop/src/renderer/src/modules/app-layout/feed-column/index.shared.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cn } from "@follow/utils/utils"
22
import { lazy, Suspense, useEffect, useState } from "react"
3+
import { useTranslation } from "react-i18next"
34
import { toast } from "sonner"
45

56
import { useWhoami } from "~/atoms/user"
@@ -21,7 +22,9 @@ export function NewUserGuide() {
2122
useEffect(() => {
2223
if (user?.email && !user.emailVerified) {
2324
toast.error(<EmailVerificationToast user={user} />, {
25+
id: "email-verification",
2426
duration: Infinity,
27+
closeButton: true,
2528
})
2629
}
2730
}, [user?.emailVerified])
@@ -40,10 +43,15 @@ function EmailVerificationToast({
4043
email: string
4144
}
4245
}) {
46+
const { t } = useTranslation("settings")
4347
const [isEmailVerificationSent, setIsEmailVerificationSent] = useState(false)
4448
return (
4549
<div data-content className="flex w-full flex-col gap-2">
46-
<div data-title>Please verify your email ({user.email}) to continue</div>
50+
<div data-title>
51+
{t("profile.email.verify_email", {
52+
email_address: user.email,
53+
})}
54+
</div>
4755
<button
4856
type="button"
4957
data-button="true"
@@ -53,15 +61,21 @@ function EmailVerificationToast({
5361
isEmailVerificationSent && "!cursor-progress opacity-50",
5462
)}
5563
disabled={isEmailVerificationSent}
56-
onClick={() => {
57-
sendVerificationEmail({
64+
onClick={async () => {
65+
setIsEmailVerificationSent(true)
66+
await sendVerificationEmail({
5867
email: user.email,
5968
callbackURL: `${WEB_URL}/login`,
6069
})
61-
setIsEmailVerificationSent(true)
70+
toast.dismiss("email-verification")
71+
// Wait for the toast to dismiss before showing the success toast
72+
// To have a better user experience
73+
setTimeout(() => {
74+
toast.success(t("profile.email.verification_sent"))
75+
}, 800)
6276
}}
6377
>
64-
Send verification email
78+
{t("profile.email.send_verification")}
6579
</button>
6680
</div>
6781
)

0 commit comments

Comments
 (0)