Hide client behind context.

Use idb for saving data.
Allow logins.
This commit is contained in:
Paul
2021-06-18 22:47:25 +01:00
parent 68a35751b3
commit ec97dbebd0
13 changed files with 474 additions and 187 deletions

View File

@@ -1,9 +1,9 @@
import { Text } from "preact-i18n";
import { useEffect } from "preact/hooks";
import styles from "../Login.module.scss";
import HCaptcha from "@hcaptcha/react-hcaptcha";
import { useContext, useEffect } from "preact/hooks";
import Preloader from "../../../components/ui/Preloader";
import { RevoltClient } from "../../../context/revoltjs/RevoltClient";
import { AppContext } from "../../../context/revoltjs/RevoltClient";
export interface CaptchaProps {
onSuccess: (token?: string) => void;
@@ -11,19 +11,21 @@ export interface CaptchaProps {
}
export function CaptchaBlock(props: CaptchaProps) {
const { client } = useContext(AppContext);
useEffect(() => {
if (!RevoltClient.configuration?.features.captcha.enabled) {
if (!client.configuration?.features.captcha.enabled) {
props.onSuccess();
}
}, []);
if (!RevoltClient.configuration?.features.captcha.enabled)
if (!client.configuration?.features.captcha.enabled)
return <Preloader />;
return (
<div>
<HCaptcha
sitekey={RevoltClient.configuration.features.captcha.key}
sitekey={client.configuration.features.captcha.key}
onVerify={token => props.onSuccess(token)}
/>
<div className={styles.footer}>