notifications: add submit button for preferences

Fixes urbit/landscape#535
This commit is contained in:
Liam Fitzgerald 2021-03-12 15:02:49 +10:00
parent f20da46745
commit 4133869957
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -4,12 +4,12 @@ import {
Text,
ManagedToggleSwitchField as Toggle,
} from "@tlon/indigo-react";
import { Form, FormikHelpers } from "formik";
import { FormikOnBlur } from "~/views/components/FormikOnBlur";
import { Formik, Form, FormikHelpers } from "formik";
import { BackButton } from "./BackButton";
import GlobalApi from "~/logic/api/global";
import useHarkState from "~/logic/state/hark";
import _ from "lodash";
import {AsyncButton} from "~/views/components/AsyncButton";
interface FormSchema {
mentions: boolean;
@ -44,12 +44,11 @@ export function NotificationPreferences(props: {
await Promise.all(promises);
actions.setStatus({ success: null });
actions.resetForm({ values: initialValues });
} catch (e) {
console.error(e);
actions.setStatus({ error: e.message });
}
}, [api]);
}, [api, graphConfig, dnd]);
return (
<>
@ -64,7 +63,7 @@ export function NotificationPreferences(props: {
messaging
</Text>
</Col>
<FormikOnBlur initialValues={initialValues} onSubmit={onSubmit}>
<Formik initialValues={initialValues} onSubmit={onSubmit}>
<Form>
<Col gapY="4">
<Toggle
@ -82,9 +81,12 @@ export function NotificationPreferences(props: {
id="mentions"
caption="Notify me if someone mentions my @p in a channel I've joined"
/>
<AsyncButton primary width="fit-content">
Save
</AsyncButton>
</Col>
</Form>
</FormikOnBlur>
</Formik>
</Col>
</>
);