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