From 64f19ec2c03365e42e8a4df5458c315d19086c78 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sun, 12 Jun 2022 19:27:18 +0100 Subject: [PATCH] chore: display error on load if present --- .../account/MultiFactorAuthentication.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/settings/account/MultiFactorAuthentication.tsx b/src/components/settings/account/MultiFactorAuthentication.tsx index d913d985..f10ca559 100644 --- a/src/components/settings/account/MultiFactorAuthentication.tsx +++ b/src/components/settings/account/MultiFactorAuthentication.tsx @@ -5,7 +5,7 @@ import { API } from "revolt.js"; import { Text } from "preact-i18n"; import { useCallback, useContext, useEffect, useState } from "preact/hooks"; -import { CategoryButton, Tip } from "@revoltchat/ui"; +import { Category, CategoryButton, Error, Tip } from "@revoltchat/ui"; import { modalController } from "../../../context/modals"; import { @@ -13,6 +13,7 @@ import { StatusContext, useClient, } from "../../../context/revoltjs/RevoltClient"; +import { takeError } from "../../../context/revoltjs/util"; /** * Temporary helper function for Axios config @@ -37,11 +38,15 @@ export default function MultiFactorAuthentication() { // Keep track of MFA state const [mfa, setMFA] = useState(); + const [error, setError] = useState(); // Fetch the current MFA status on account useEffect(() => { if (!mfa && status === ClientStatus.ONLINE) { - client.api.get("/auth/mfa/").then(setMFA); + client.api + .get("/auth/mfa/") + .then(setMFA) + .catch((err) => setError(takeError(err))); } }, [client, mfa, status]); @@ -159,6 +164,12 @@ export default function MultiFactorAuthentication() { + {error && ( + + + + )} + } description={