mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 03:23:09 +03:00
interface: update settings callsites
This commit is contained in:
parent
8745980f56
commit
b8f3296320
@ -45,7 +45,7 @@ export interface SettingsState {
|
|||||||
keyboard: ShortcutMapping;
|
keyboard: ShortcutMapping;
|
||||||
remoteContentPolicy: RemoteContentPolicy;
|
remoteContentPolicy: RemoteContentPolicy;
|
||||||
getAll: () => Promise<void>;
|
getAll: () => Promise<void>;
|
||||||
putEntry: (bucket: string, key: string, value: Value) => void;
|
putEntry: (bucket: string, key: string, value: Value) => Promise<void>;
|
||||||
leap: {
|
leap: {
|
||||||
categories: LeapCategories[];
|
categories: LeapCategories[];
|
||||||
};
|
};
|
||||||
@ -108,7 +108,7 @@ const useSettingsState = createState<SettingsState>(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
putEntry: (bucket: string, entry: string, value: Value) => {
|
putEntry: async (bucket: string, entry: string, value: Value) => {
|
||||||
const poke = putEntry((window as any).desk, bucket, entry, value);
|
const poke = putEntry((window as any).desk, bucket, entry, value);
|
||||||
pokeOptimisticallyN(useSettingsState, poke, reduceUpdate);
|
pokeOptimisticallyN(useSettingsState, poke, reduceUpdate);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import Tiles from './components/tiles';
|
|||||||
import Tile from './components/tiles/tile';
|
import Tile from './components/tiles/tile';
|
||||||
import './css/custom.css';
|
import './css/custom.css';
|
||||||
import { join } from '@urbit/api/groups';
|
import { join } from '@urbit/api/groups';
|
||||||
import { putEntry } from '@urbit/api/settings';
|
|
||||||
import { joinGraph } from '@urbit/api/graph';
|
import { joinGraph } from '@urbit/api/graph';
|
||||||
import airlock from '~/logic/api';
|
import airlock from '~/logic/api';
|
||||||
|
|
||||||
@ -103,15 +102,17 @@ export const LaunchApp = (props: LaunchAppProps): ReactElement | null => {
|
|||||||
maxWidth: '350px',
|
maxWidth: '350px',
|
||||||
modal: function modal(dismiss) {
|
modal: function modal(dismiss) {
|
||||||
const onDismiss = (e) => {
|
const onDismiss = (e) => {
|
||||||
|
const { putEntry } = useSettingsState.getState();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
airlock.poke(putEntry('tutorial', 'seen', true));
|
putEntry('tutorial', 'seen', true);
|
||||||
dismiss();
|
dismiss();
|
||||||
};
|
};
|
||||||
const onContinue = async (e) => {
|
const onContinue = async (e) => {
|
||||||
|
const { putEntry } = useSettingsState.getState();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!hasTutorialGroup({ associations })) {
|
if (!hasTutorialGroup({ associations })) {
|
||||||
await airlock.poke(join(TUTORIAL_HOST, TUTORIAL_GROUP));
|
await airlock.poke(join(TUTORIAL_HOST, TUTORIAL_GROUP));
|
||||||
await airlock.poke(putEntry('tutorial', 'joined', Date.now()));
|
await putEntry('tutorial', 'joined', Date.now());
|
||||||
await waiter(hasTutorialGroup);
|
await waiter(hasTutorialGroup);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[TUTORIAL_BOOK, TUTORIAL_CHAT, TUTORIAL_LINKS].map(graph => airlock.thread(joinGraph(TUTORIAL_HOST, graph))));
|
[TUTORIAL_BOOK, TUTORIAL_CHAT, TUTORIAL_LINKS].map(graph => airlock.thread(joinGraph(TUTORIAL_HOST, graph))));
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
ManagedCheckboxField, Text
|
ManagedCheckboxField, Text
|
||||||
} from '@tlon/indigo-react';
|
} from '@tlon/indigo-react';
|
||||||
import { Form, useFormikContext } from 'formik';
|
import { Form, useFormikContext } from 'formik';
|
||||||
import { putEntry } from '@urbit/api/settings';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import useSettingsState, { selectSettingsState } from '~/logic/state/settings';
|
import useSettingsState, { selectSettingsState } from '~/logic/state/settings';
|
||||||
@ -15,7 +14,6 @@ import {
|
|||||||
import { FormikOnBlur } from '~/views/components/FormikOnBlur';
|
import { FormikOnBlur } from '~/views/components/FormikOnBlur';
|
||||||
import { ShuffleFields } from '~/views/components/ShuffleFields';
|
import { ShuffleFields } from '~/views/components/ShuffleFields';
|
||||||
import { BackButton } from './BackButton';
|
import { BackButton } from './BackButton';
|
||||||
import airlock from '~/logic/api';
|
|
||||||
|
|
||||||
const labels: Record<LeapCategories, string> = {
|
const labels: Record<LeapCategories, string> = {
|
||||||
mychannel: 'My Channels',
|
mychannel: 'My Channels',
|
||||||
@ -60,11 +58,12 @@ export function LeapSettings() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (values: FormSchema) => {
|
const onSubmit = async (values: FormSchema) => {
|
||||||
|
const { putEntry } = useSettingsState.getState();
|
||||||
const result = values.categories.reduce(
|
const result = values.categories.reduce(
|
||||||
(acc, { display, category }) => (display ? [...acc, category] : acc),
|
(acc, { display, category }) => (display ? [...acc, category] : acc),
|
||||||
[] as LeapCategories[]
|
[] as LeapCategories[]
|
||||||
);
|
);
|
||||||
await airlock.poke(putEntry('leap', 'categories', result));
|
await putEntry('leap', 'categories', result);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -3,7 +3,6 @@ import _ from 'lodash';
|
|||||||
|
|
||||||
import { Box, Col, Text } from '@tlon/indigo-react';
|
import { Box, Col, Text } from '@tlon/indigo-react';
|
||||||
import { Formik, Form, useField } from 'formik';
|
import { Formik, Form, useField } from 'formik';
|
||||||
import { putEntry } from '@urbit/api/settings';
|
|
||||||
|
|
||||||
import { getChord } from '~/logic/lib/util';
|
import { getChord } from '~/logic/lib/util';
|
||||||
import useSettingsState, {
|
import useSettingsState, {
|
||||||
@ -12,7 +11,6 @@ import useSettingsState, {
|
|||||||
} from '~/logic/state/settings';
|
} from '~/logic/state/settings';
|
||||||
import { AsyncButton } from '~/views/components/AsyncButton';
|
import { AsyncButton } from '~/views/components/AsyncButton';
|
||||||
import { BackButton } from './BackButton';
|
import { BackButton } from './BackButton';
|
||||||
import airlock from '~/logic/api';
|
|
||||||
|
|
||||||
const settingsSel = selectSettingsState(['keyboard']);
|
const settingsSel = selectSettingsState(['keyboard']);
|
||||||
|
|
||||||
@ -69,9 +67,10 @@ export default function ShortcutSettings() {
|
|||||||
initialValues={keyboard}
|
initialValues={keyboard}
|
||||||
onSubmit={async (values: ShortcutMapping, actions) => {
|
onSubmit={async (values: ShortcutMapping, actions) => {
|
||||||
const promises = _.map(values, (value, key) => {
|
const promises = _.map(values, (value, key) => {
|
||||||
|
const { putEntry } = useSettingsState.getState();
|
||||||
return keyboard[key] !== value
|
return keyboard[key] !== value
|
||||||
? airlock.poke(putEntry('keyboard', key, value))
|
? putEntry('keyboard', key, value)
|
||||||
: Promise.resolve(0);
|
: Promise.resolve();
|
||||||
});
|
});
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
actions.setStatus({ success: null });
|
actions.setStatus({ success: null });
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
ManagedTextInputField as Input, Row,
|
ManagedTextInputField as Input, Row,
|
||||||
Text
|
Text
|
||||||
} from '@tlon/indigo-react';
|
} from '@tlon/indigo-react';
|
||||||
import { join, MetadataUpdatePreview, putEntry } from '@urbit/api';
|
import { join, MetadataUpdatePreview } from '@urbit/api';
|
||||||
import { Form, Formik, FormikHelpers, useFormikContext } from 'formik';
|
import { Form, Formik, FormikHelpers, useFormikContext } from 'formik';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
|
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
|
||||||
@ -22,6 +22,7 @@ import { FormError } from '~/views/components/FormError';
|
|||||||
import { StatelessAsyncButton } from '~/views/components/StatelessAsyncButton';
|
import { StatelessAsyncButton } from '~/views/components/StatelessAsyncButton';
|
||||||
import { GroupSummary } from './GroupSummary';
|
import { GroupSummary } from './GroupSummary';
|
||||||
import airlock from '~/logic/api';
|
import airlock from '~/logic/api';
|
||||||
|
import useSettingsState from '~/logic/state/settings';
|
||||||
|
|
||||||
const formSchema = Yup.object({
|
const formSchema = Yup.object({
|
||||||
group: Yup.string()
|
group: Yup.string()
|
||||||
@ -73,8 +74,9 @@ export function JoinGroup(props: JoinGroupProps): ReactElement {
|
|||||||
|
|
||||||
const onConfirm = useCallback(async (group: string) => {
|
const onConfirm = useCallback(async (group: string) => {
|
||||||
const [,,ship,name] = group.split('/');
|
const [,,ship,name] = group.split('/');
|
||||||
|
const { putEntry } = useSettingsState.getState();
|
||||||
if(group === TUTORIAL_GROUP_RESOURCE) {
|
if(group === TUTORIAL_GROUP_RESOURCE) {
|
||||||
await airlock.poke(putEntry('tutorial', 'joined', Date.now()));
|
await putEntry('tutorial', 'joined', Date.now());
|
||||||
}
|
}
|
||||||
if (group in groups) {
|
if (group in groups) {
|
||||||
return history.push(`/~landscape${group}`);
|
return history.push(`/~landscape${group}`);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Box, Button, Col, Icon, Row, Text } from '@tlon/indigo-react';
|
import { Box, Button, Col, Icon, Row, Text } from '@tlon/indigo-react';
|
||||||
import { leaveGroup, putEntry } from '@urbit/api';
|
import { leaveGroup } from '@urbit/api';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@ -16,6 +16,7 @@ import { Portal } from '~/views/components/Portal';
|
|||||||
import { StatelessAsyncButton } from '~/views/components/StatelessAsyncButton';
|
import { StatelessAsyncButton } from '~/views/components/StatelessAsyncButton';
|
||||||
import { Triangle } from '~/views/components/Triangle';
|
import { Triangle } from '~/views/components/Triangle';
|
||||||
import airlock from '~/logic/api';
|
import airlock from '~/logic/api';
|
||||||
|
import useSettingsState from '~/logic/state/settings';
|
||||||
|
|
||||||
const localSelector = selectLocalState([
|
const localSelector = selectLocalState([
|
||||||
'tutorialProgress',
|
'tutorialProgress',
|
||||||
@ -94,7 +95,8 @@ export function TutorialModal() {
|
|||||||
const dismiss = useCallback(async () => {
|
const dismiss = useCallback(async () => {
|
||||||
setPaused(false);
|
setPaused(false);
|
||||||
hideTutorial();
|
hideTutorial();
|
||||||
await airlock.poke(putEntry('tutorial', 'seen', true));
|
const { putEntry } = useSettingsState.getState();
|
||||||
|
await putEntry('tutorial', 'seen', true);
|
||||||
}, [hideTutorial]);
|
}, [hideTutorial]);
|
||||||
|
|
||||||
const bailExit = useCallback(() => {
|
const bailExit = useCallback(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user