CalmEngine: do not wait for success
@@ -3,11 +3,10 @@ import {
Text
} from '@tlon/indigo-react';
-import { Form, Formik, FormikHelpers } from 'formik';
+import { Form } from 'formik';
import React, { useCallback } from 'react';
import GlobalApi from '~/logic/api/global';
-import useSettingsState, { selectSettingsState, SettingsState } from '~/logic/state/settings';
-import { AsyncButton } from '~/views/components/AsyncButton';
+import useSettingsState, { SettingsState } from '~/logic/state/settings';
import { BackButton } from './BackButton';
import _ from 'lodash';
import { FormikOnBlur } from '~/views/components/FormikOnBlur';
@@ -36,23 +35,19 @@ const settingsSel = (s: SettingsState): FormSchema => ({
audioShown: !s.remoteContentPolicy.audioShown
});
-
export function CalmPrefs(props: {
api: GlobalApi;
}) {
const { api } = props;
const initialValues = useSettingsState(settingsSel);
- const onSubmit = useCallback(async (v: FormSchema, actions: FormikHelpers<FormSchema>) => {
- let promises: Promise<any>[] = [];
+ const onSubmit = useCallback(async (v: FormSchema) => {
_.forEach(v, (bool, key) => {
const bucket = ['imageShown', 'videoShown', 'audioShown', 'oembedShown'].includes(key) ? 'remoteContentPolicy' : 'calm';
if(initialValues[key] !== bool) {
- promises.push(api.settings.putEntry(bucket, key, bool));
+ api.settings.putEntry(bucket, key, bool);
}
- })
- await Promise.all(promises);
- actions.setStatus({ success: null });
+ });
}, [api]);
return (
