Preferences: prefer custom hooks
This commit is contained in:
parent
5a8bae5126
commit
faa02ecc3d
1 changed files with 4 additions and 6 deletions
|
@ -2,13 +2,12 @@ import React from 'react';
|
||||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
|
|
||||||
import { getSettings, changeSetting } from 'soapbox/actions/settings';
|
import { changeSetting } from 'soapbox/actions/settings';
|
||||||
import List, { ListItem } from 'soapbox/components/list';
|
import List, { ListItem } from 'soapbox/components/list';
|
||||||
import { Form } from 'soapbox/components/ui';
|
import { Form } from 'soapbox/components/ui';
|
||||||
import { SelectDropdown } from 'soapbox/features/forms';
|
import { SelectDropdown } from 'soapbox/features/forms';
|
||||||
import SettingToggle from 'soapbox/features/notifications/components/setting_toggle';
|
import SettingToggle from 'soapbox/features/notifications/components/setting_toggle';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useFeatures, useSettings } from 'soapbox/hooks';
|
||||||
import { getFeatures } from 'soapbox/utils/features';
|
|
||||||
|
|
||||||
import ThemeToggle from '../ui/components/theme-toggle';
|
import ThemeToggle from '../ui/components/theme-toggle';
|
||||||
|
|
||||||
|
@ -91,9 +90,8 @@ const messages = defineMessages({
|
||||||
const Preferences = () => {
|
const Preferences = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const features = useFeatures();
|
||||||
const features = useAppSelector((state) => getFeatures(state.instance));
|
const settings = useSettings();
|
||||||
const settings = useAppSelector((state) => getSettings(state));
|
|
||||||
|
|
||||||
const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, path: string[]) => {
|
const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, path: string[]) => {
|
||||||
dispatch(changeSetting(path, event.target.value, { showAlert: true }));
|
dispatch(changeSetting(path, event.target.value, { showAlert: true }));
|
||||||
|
|
Loading…
Reference in a new issue