- API:{" "}
- {client.configuration?.revolt ?? "???"}
{" "}
+ API: {configuration?.revolt ?? "???"}
{" "}
· revolt.js: {LIBRARY_VERSION}
{" "}
· App: {APP_VERSION}
@@ -80,4 +82,4 @@ export default function Login() {
>
);
-}
+});
diff --git a/src/pages/login/forms/CaptchaBlock.tsx b/src/pages/login/forms/CaptchaBlock.tsx
index 51548c6b..09addd16 100644
--- a/src/pages/login/forms/CaptchaBlock.tsx
+++ b/src/pages/login/forms/CaptchaBlock.tsx
@@ -1,10 +1,11 @@
import HCaptcha from "@hcaptcha/react-hcaptcha";
+import { observer } from "mobx-react-lite";
import styles from "../Login.module.scss";
import { Text } from "preact-i18n";
-import { useContext, useEffect } from "preact/hooks";
+import { useEffect } from "preact/hooks";
-import { AppContext } from "../../../context/revoltjs/RevoltClient";
+import { useApplicationState } from "../../../mobx/State";
import Preloader from "../../../components/ui/Preloader";
@@ -13,22 +14,22 @@ export interface CaptchaProps {
onCancel: () => void;
}
-export function CaptchaBlock(props: CaptchaProps) {
- const client = useContext(AppContext);
+export const CaptchaBlock = observer((props: CaptchaProps) => {
+ const configuration = useApplicationState().config.get();
useEffect(() => {
- if (!client.configuration?.features.captcha.enabled) {
+ if (!configuration?.features.captcha.enabled) {
props.onSuccess();
}
- }, [client.configuration?.features.captcha.enabled, props]);
+ }, [configuration?.features.captcha.enabled, props]);
- if (!client.configuration?.features.captcha.enabled)
+ if (!configuration?.features.captcha.enabled)
return
;
return (
props.onSuccess(token)}
/>
@@ -38,4 +39,4 @@ export function CaptchaBlock(props: CaptchaProps) {
);
-}
+});
diff --git a/src/pages/login/forms/Form.tsx b/src/pages/login/forms/Form.tsx
index b11dbe91..35a6e14e 100644
--- a/src/pages/login/forms/Form.tsx
+++ b/src/pages/login/forms/Form.tsx
@@ -6,6 +6,8 @@ import styles from "../Login.module.scss";
import { Text } from "preact-i18n";
import { useContext, useState } from "preact/hooks";
+import { useApplicationState } from "../../../mobx/State";
+
import { AppContext } from "../../../context/revoltjs/RevoltClient";
import { takeError } from "../../../context/revoltjs/util";
@@ -44,7 +46,7 @@ interface FormInputs {
}
export function Form({ page, callback }: Props) {
- const client = useContext(AppContext);
+ const configuration = useApplicationState().config.get();
const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState
(undefined);
@@ -80,10 +82,7 @@ export function Form({ page, callback }: Props) {
}
try {
- if (
- client.configuration?.features.captcha.enabled &&
- page !== "reset"
- ) {
+ if (configuration?.features.captcha.enabled && page !== "reset") {
setCaptcha({
onSuccess: async (captcha) => {
setCaptcha(undefined);
@@ -111,7 +110,7 @@ export function Form({ page, callback }: Props) {
if (typeof success !== "undefined") {
return (
- {client.configuration?.features.email ? (
+ {configuration?.features.email ? (
<>
@@ -172,15 +171,14 @@ export function Form({ page, callback }: Props) {
error={errors.password?.message}
/>
)}
- {client.configuration?.features.invite_only &&
- page === "create" && (
-
- )}
+ {configuration?.features.invite_only && page === "create" && (
+
+ )}
{error && (
diff --git a/src/pages/login/forms/FormCreate.tsx b/src/pages/login/forms/FormCreate.tsx
index 677aeba3..8d2e9ed7 100644
--- a/src/pages/login/forms/FormCreate.tsx
+++ b/src/pages/login/forms/FormCreate.tsx
@@ -1,10 +1,9 @@
-import { useContext } from "preact/hooks";
-
-import { AppContext } from "../../../context/revoltjs/RevoltClient";
+import { useApplicationState } from "../../../mobx/State";
import { Form } from "./Form";
export function FormCreate() {
- const client = useContext(AppContext);
+ const config = useApplicationState().config;
+ const client = config.createClient();
return