mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
CalmEngine: do not wait for success
This commit is contained in:
parent
5ba7a2fe52
commit
520da1ed71
@ -3,14 +3,13 @@ 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';
|
||||
import { FormikOnBlur } from '~/views/components/FormikOnBlur';
|
||||
|
||||
interface FormSchema {
|
||||
hideAvatars: boolean;
|
||||
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user