import { At } from "@styled-icons/boxicons-regular"; import { Envelope, Key, HelpCircle } from "@styled-icons/boxicons-solid"; import { Link, useHistory } from "react-router-dom"; import { Users } from "revolt.js/dist/api/objects"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { ClientStatus, StatusContext, } from "../../../context/revoltjs/RevoltClient"; import { useForceUpdate, useSelf } from "../../../context/revoltjs/hooks"; import Tooltip from "../../../components/common/Tooltip"; import UserIcon from "../../../components/common/user/UserIcon"; import Button from "../../../components/ui/Button"; import Overline from "../../../components/ui/Overline"; import Tip from "../../../components/ui/Tip"; export function Account() { const { openScreen, writeClipboard } = useIntermediate(); const status = useContext(StatusContext); const ctx = useForceUpdate(); const user = useSelf(ctx); if (!user) return null; const [email, setEmail] = useState("..."); const [revealEmail, setRevealEmail] = useState(false); const [profile, setProfile] = useState( undefined, ); const history = useHistory(); function switchPage(to: string) { history.replace(`/settings/${to}`); } useEffect(() => { if (email === "..." && status === ClientStatus.ONLINE) { ctx.client .req("GET", "/auth/user") .then((account) => setEmail(account.email)); } if (profile === undefined && status === ClientStatus.ONLINE) { ctx.client.users .fetchProfile(user._id) .then((profile) => setProfile(profile ?? {})); } }, [status]); return (
switchPage("profile")} />
@{user.username}
{( [ ["username", user.username, ], ["email", email, ], ["password", "***********", ], ] as const ).map(([field, value, icon]) => (
{icon}

{field === "email" ? ( revealEmail ? ( value ) : ( <> ***********@{value.split("@").pop()}{" "} setRevealEmail(true) }> ) ) : ( value )}

))}

Currently work in progress, see{" "} tracking issue here .
{/*
*/}

{/* */}
{" "} switchPage("profile")}>
); }